public Method

ClassMethods.create!(attributes = nil)

Creates an object just like Base.create but calls save! instead of save so an exception is raised if the record is invalid.

Source Code

# File active_record/validations.rb, line 904
def create!(attributes = nil)
  if attributes.is_a?(Array)
    attributes.collect { |attr| create!(attr) }
  else
    object = new(attributes)
    object.save!
    object
  end
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.