instance method
take
Ruby on Rails 6.1.7.10
Since v4.0.13Signature
take(limit = nil)
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
Parameters
-
limitopt = nil
Source
# File activerecord/lib/active_record/relation/finder_methods.rb, line 97
def take(limit = nil)
limit ? find_take_with_limit(limit) : find_take
end
Defined in activerecord/lib/active_record/relation/finder_methods.rb line 97
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::FinderMethods