instance method
first_or_initialize
Ruby on Rails 3.2.22.5
Since v3.2.22.5 Last seen in v3.2.22.5Signature
first_or_initialize(attributes = nil, options = {}, &block)
Like first_or_create but calls new instead of create.
Expects arguments in the same format as Base.new.
Parameters
-
attributesopt = nil -
optionsopt = {} -
blockblock
Source
# File activerecord/lib/active_record/relation.rb, line 131
def first_or_initialize(attributes = nil, options = {}, &block)
first || new(attributes, options, &block)
end
Defined in activerecord/lib/active_record/relation.rb line 131
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Relation