instance method
attributes
Ruby on Rails edge
Since v7.1.6Signature
attributes()
Returns a hash of all the attributes with their names as keys and the values of the attributes as values.
class Person
include ActiveModel::Attributes
attribute :name, :string
attribute :age, :integer
end
person = Person.new
person.name = "Francesco"
person.age = 22
person.attributes # => { "name" => "Francesco", "age" => 22}
Source
# File activemodel/lib/active_model/attributes.rb, line 135
def attributes
@attributes.to_hash
end
Defined in activemodel/lib/active_model/attributes.rb line 135
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveModel::Attributes