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