take!

take!() Instance Public methods Same as take but raises ActiveRecord::RecordNotFound if no record is found. Note that take! accepts no arguments.

take

take(limit = nil) Instance Public methods Gives a record (or N records if a parameter is supplied) without any implied order. The order will depend on the database implementation. If an order is supplied it will be respected. Person.take # returns an object fetched by SELECT * FROM people LIMIT 1 Person.take(5) # returns 5 objects fetched by SELECT * FROM people LIMIT 5 Person.where(["name LIKE '%?'", name]).take

second!

second!() Instance Public methods Same as second but raises ActiveRecord::RecordNotFound if no record is found.

second

second() Instance Public methods Find the second record. If no order is defined it will order by primary key. Person.second # returns the second object fetched by SELECT * FROM people Person.offset(3).second # returns the second object from OFFSET 3 (which is OFFSET 4) Person.where(["user_name = :u", { u: user_name }]).second

last!

last!() Instance Public methods Same as last but raises ActiveRecord::RecordNotFound if no record is found. Note that last! accepts no arguments.

last

last(limit = nil) Instance Public methods Find the last record (or last N records if a parameter is supplied). If no order is defined it will order by primary key. Person.last # returns the last object fetched by SELECT * FROM people Person.where(["user_name = ?", user_name]).last Person.order("created_on DESC").offset(5).last Person.last(3) # returns the last three objects fetched by SELECT * FROM people. Take note that in that last case, the results are sorted in ascending order

fourth!

fourth!() Instance Public methods Same as fourth but raises ActiveRecord::RecordNotFound if no record is found.

fourth

fourth() Instance Public methods Find the fourth record. If no order is defined it will order by primary key. Person.fourth # returns the fourth object fetched by SELECT * FROM people Person.offset(3).fourth # returns the fourth object from OFFSET 3 (which is OFFSET 6) Person.where(["user_name = :u", { u: user_name }]).fourth

forty_two!

forty_two!() Instance Public methods Same as forty_two but raises ActiveRecord::RecordNotFound if no record is found.

forty_two

forty_two() Instance Public methods Find the forty-second record. Also known as accessing âthe redditâ. If no order is defined it will order by primary key. Person.forty_two # returns the forty-second object fetched by SELECT * FROM people Person.offset(3).forty_two # returns the forty-second object from OFFSET 3 (which is OFFSET 44) Person.where(["user_name = :u", { u: user_name }]).forty_two