Method: ActiveRecord::FinderMethods#take
- Defined in:
- lib/active_record/relation/finder_methods.rb
#take(limit = nil) ⇒ Object
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
128 129 130 |
# File 'lib/active_record/relation/finder_methods.rb', line 128 def take(limit = nil) limit ? find_take_with_limit(limit) : find_take end |