more complex your search queries becomes, the uglier your SQL statements get, even with ActiveRecord's helpful magic. Reclaim some clarity in your code by using the Sphinx search engine, a powerful tool that lets you search across your models in fast and complex ways.
interacting with Web applications, helps you write expressive, maintainable acceptance tests while sidestepping the issues traditionally associated with in-browser approaches like Selenium and Watir. We'll look at how you can use Webrat to develop a robust acceptance test suite to ensure your app stays working as you refactor mercilessly.
Ruby and Rails community is now using Git, but there are a number of fun things that are a bit more difficult to get the hang of that are incredibly helpful to know when using Git. This session will go over some advanced Git usage for the casual or intermediate Git user.
as a directed acyclic graph of commit objects pointing to snapshots of content, with all data saved in it's own custom content addressable filesystem by the SHA-1 checksum hash of each objects data. Branches are simply pointers into this directed graph of commits, identifying entry points that designate the latest work on that branch, allowing Git to traverse the pointers, determining a coherent history. This makes branching cheap and easy, and merging simple, encouraging non-linear development styles and frictionless context switching while facilitating distributed development, cryptographic integrity and late decision making. Nearly all commands run locally with no network latency overhead and it is implemented mainly in C, making it incredibly fast and efficient even for very large projects. There are several large open source projects using it, not to mention the 100,000 open source repositories maintained by the 80,000 developers on GitHub alone. https://gist.github.com/schacon/111475
migrations rake data:migrate:down # Revert single data migration using VERSION rake data:migrate:pending # List pending migrations rake data:migrate:skip # Skip single data migration using VERSION rake data:migrate:up # Apply single data migration using VERSION
# id :integer not null, primary key # name :string # username :string # password :string # active :boolean # created_at :datetime not null # updated_at :datetime not null # class User < ApplicationRecord end
# id :integer not null, primary key # title :string # description :text # author_id :integer # created_at :datetime not null # updated_at :datetime not null # class Book < ApplicationRecord belongs_to :author has_many :comments end
# id :integer not null, primary key # name :string # created_at :datetime not null # updated_at :datetime not null # class Author < ApplicationRecord end
by BooksController#index as HTML Rendering books/index.html.erb within layouts/application Book Load (0.3ms) SELECT "books".* FROM "books" Author Load (0.1ms) SELECT "authors".* FROM "authors" WHERE "authors"."id" = ? L Comment Load (0.1ms) SELECT "comments".* FROM "comments" WHERE "comments"."book_i User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? Author Load (0.1ms) SELECT "authors".* FROM "authors" WHERE "authors"."id" = ? L Comment Load (0.1ms) SELECT "comments".* FROM "comments" WHERE "comments"."book_i CACHE User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIM CACHE Author Load (0.0ms) SELECT "authors".* FROM "authors" WHERE "authors"."id" Comment Load (0.1ms) SELECT "comments".* FROM "comments" WHERE "comments"."book_i CACHE User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIM CACHE Author Load (0.0ms) SELECT "authors".* FROM "authors" WHERE "authors"."id" Comment Load (0.1ms) SELECT "comments".* FROM "comments" WHERE "comments"."book_i CACHE User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIM Author Load (0.1ms) SELECT "authors".* FROM "authors" WHERE "authors"."id" = ? L Comment Load (0.1ms) SELECT "comments".* FROM "comments" WHERE "comments"."book_i CACHE User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIM Rendered books/index.html.erb within layouts/application (19.0ms) Completed 200 OK in 30ms (Views: 26.4ms | ActiveRecord: 1.5ms)
by BooksController#index as HTML Rendering books/index.html.erb within layouts/application Book Load (0.3ms) SELECT "books".* FROM "books" Author Load (0.1ms) SELECT "authors".* FROM "authors" WHERE "authors"."id" = ? L Comment Load (0.1ms) SELECT "comments".* FROM "comments" WHERE "comments"."book_i User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? Author Load (0.1ms) SELECT "authors".* FROM "authors" WHERE "authors"."id" = ? L Comment Load (0.1ms) SELECT "comments".* FROM "comments" WHERE "comments"."book_i CACHE User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIM CACHE Author Load (0.0ms) SELECT "authors".* FROM "authors" WHERE "authors"."id" Comment Load (0.1ms) SELECT "comments".* FROM "comments" WHERE "comments"."book_i CACHE User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIM CACHE Author Load (0.0ms) SELECT "authors".* FROM "authors" WHERE "authors"."id" Comment Load (0.1ms) SELECT "comments".* FROM "comments" WHERE "comments"."book_i CACHE User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIM Author Load (0.1ms) SELECT "authors".* FROM "authors" WHERE "authors"."id" = ? L Comment Load (0.1ms) SELECT "comments".* FROM "comments" WHERE "comments"."book_i CACHE User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIM Rendered books/index.html.erb within layouts/application (19.0ms) Completed 200 OK in 30ms (Views: 26.4ms | ActiveRecord: 1.5ms)
by BooksController#index as HTML Rendering books/index.html.erb within layouts/application Book Load (0.1ms) SELECT "books".* FROM "books" Author Load (0.2ms) SELECT "authors".* FROM "authors" WHERE "authors"."id" IN (1, Comment Load (0.2ms) SELECT "comments".* FROM "comments" WHERE "comments"."book_i User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 Rendered books/index.html.erb within layouts/application (61.6ms) Completed 200 OK in 92ms (Views: 73.1ms | ActiveRecord: 3.5ms)
by BooksController#index as HTML Rendering books/index.html.erb within layouts/application Book Load (0.1ms) SELECT "books".* FROM "books" Author Load (0.2ms) SELECT "authors".* FROM "authors" WHERE "authors"."id" IN (1, Comment Load (0.2ms) SELECT "comments".* FROM "comments" WHERE "comments"."book_i User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 Rendered books/index.html.erb within layouts/application (61.6ms) Completed 200 OK in 92ms (Views: 73.1ms | ActiveRecord: 3.5ms)
SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY " Processing by BooksController#index as HTML Rendering books/index.html.erb within layouts/application Book Load (0.2ms) SELECT "books".* FROM "books" Author Load (0.1ms) SELECT "authors".* FROM "authors" WHERE "authors"."id" IN (1, Comment Load (0.1ms) SELECT "comments".* FROM "comments" WHERE "comments"."book_i User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 Rendered books/index.html.erb within layouts/application (50.1ms) Completed 200 OK in 116ms (Views: 94.4ms | ActiveRecord: 2.6ms) Oink Action: books#index Memory usage: 2596436 | PID: 31331 Instantiation Breakdown: Total: 14 | Book: 5 | Comment: 5 | Author: 3 | User: 1 Oink Log Entry Complete
SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY " Processing by BooksController#index as HTML Rendering books/index.html.erb within layouts/application Book Load (0.2ms) SELECT "books".* FROM "books" Author Load (0.1ms) SELECT "authors".* FROM "authors" WHERE "authors"."id" IN (1, Comment Load (0.1ms) SELECT "comments".* FROM "comments" WHERE "comments"."book_i User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 Rendered books/index.html.erb within layouts/application (50.1ms) Completed 200 OK in 116ms (Views: 94.4ms | ActiveRecord: 2.6ms) Oink Action: books#index Memory usage: 2596436 | PID: 31331 Instantiation Breakdown: Total: 14 | Book: 5 | Comment: 5 | Author: 3 | User: 1 Oink Log Entry Complete