instance method first_or_create!

Ruby on Rails 3.2.22.5

Since v3.2.22.5 Last seen in v3.2.22.5

Signature

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

attributes opt = nil
options opt = {}
block block
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

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close