instance method
first
Ruby on Rails 5.1.7
Since v5.0.7.2 Last seen in v6.0.6.1Signature
first()
Returns the first record from the rows collection. If the rows collection is empty, returns nil.
Source
# File activerecord/lib/active_record/result.rb, line 85
def first
return nil if @rows.empty?
Hash[@columns.zip(@rows.first)]
end
Defined in activerecord/lib/active_record/result.rb line 85
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Result