Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Under The Hood of Rails’ ‘find’ Method

By Peter Cooper / December 5, 2006


Jamis Buck has put together a cool series of articles about ActiveRecord's find method as used in Rails. He goes into a lot of detail about how find and its related methods work in terms of the internals of ActiveRecord. Jamis' explanations are not only useful for Rails developers, but for anyone interested in patterns and how to structure code in Ruby. The Rails team don't always do everything the 'best' way, but it's usually tight, well developed code you can learn a lot from.

In the first installment, Jamis just presents a basic introduction to his series.

In the second installment, he leaps right in to the details of find and its child methods, find_from_ids, find_every and find_initial. If you want to see how the find methods put together the correct SQL queries, it's a must read, and it takes away a lot of the 'mystery' of the black box that is ActiveRecord.

In the latest, third, installment, Jamis looks at dynamic finders (e.g. find_by_username_and_password and similar).

Hopefully Jamis will keep posting stuff like this because it makes fascinating reading.

Other Posts to Enjoy

Twitter Mentions