create!(attributes = {}, &block)
Instance Public methods
Like create
, except that if the record is invalid, raises an
exception.
1 2 3 4 5 6 7 8 9 10 | 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 |
Please login to continue.