class method
self.new
Ruby on Rails 7.0.10
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 80
def initialize(attributes = {})
assign_attributes(attributes) if attributes
super()
end
Defined in activemodel/lib/active_model/api.rb line 80
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveModel::API