Flowdock
method

create!

Importance_1
create!(attributes = {}, &block) public

Like create, except that if the record is invalid, raises an exception.

class Person
  has_many :pets
end

class Pet
  validates :name, presence: true
end

person.pets.create!(name: nil)
# => ActiveRecord::RecordInvalid: Validation failed: Name can't be blank
Show source
Register or log in to add new notes.