28 Mar '14, 7pm

ActiveRecord FinderMethods @rubyonrails

Find by id - This can either be a specific id (1), a list of ids (1, 5, 6), or an array of ids ([5, 6, 10]). If no record can be found for all of the listed ids, then RecordNotFound will be raised. If the primary key is an integer, find by id coerces its arguments using to_i . Person.find(1) # returns the object for ID = 1 Person.find("1") # returns the object for ID = 1 Person.find("31-sarah") # returns the object for ID = 31 Person.find(1, 2, 6) # returns an array for objects with IDs in (1, 2, 6) Person.find([7, 17]) # returns an array for objects with IDs in (7, 17) Person.find([1]) # returns an array for the object with ID = 1 Person.where("administrator = 1").order("created_on DESC").find(1) Note that returned records may not be in the same order as the ids you provide since database rows are unordered. Give an explicit order to ensure the results are sorted. Find wi...

Full article: http://api.rubyonrails.org/classes/ActiveRecord/FinderMet...

Tweets

BigBroda - ActiveRecord adapter for Google BigQ...

rubyflow.com 25 Mar '14, 3am

BigBroda - ActiveRecord adapter for Google BigQuery Posted by michelson on March 25, 2014 — 0 comments BigBroda is an Acti...

acts_as_tree (1.5.1): A gem that adds simple su...

rubygems.org 28 Mar '14, 8pm

A gem that adds simple support for organizing ActiveRecord models into parent–children relationships.