Flowdock
method

create!

Importance_1
Ruby on Rails latest stable (v4.1.8) - 0 notes - Class: CollectionProxy
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.