class method
self.new
Ruby on Rails edge
Since v7.0.10Signature
self.new(attributes = {})
Initializes a new model with the given params.
class Person
include ActiveModel::API
attr_accessor :name, :age
end
person = Person.new(name: 'bob', age: '18')
person.name # => "bob"
person.age # => "18"
Parameters
-
attributesopt = {}
Source
# File activemodel/lib/active_model/api.rb, line 81
def initialize(attributes = {})
assign_attributes(attributes) if attributes
super()
end
Defined in activemodel/lib/active_model/api.rb line 81
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveModel::API