instance method
attributes
Ruby on Rails 7.1.6
Since v4.0.13Signature
attributes()
Returns a hash of all the attributes with their names as keys and the values of the attributes as values.
class Person < ActiveRecord::Base end person = Person.create(name: 'Francesco', age: 22) person.attributes # => {"id"=>3, "created_at"=>Sun, 21 Oct 2012 04:53:04, "updated_at"=>Sun, 21 Oct 2012 04:53:04, "name"=>"Francesco", "age"=>22}
Source
# File activerecord/lib/active_record/attribute_methods.rb, line 354
def attributes
@attributes.to_hash
end
Defined in activerecord/lib/active_record/attribute_methods.rb line 354
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::AttributeMethods