Where can I find details about the 'save' method used in rails?
I'm not sure if this is a rails method or a ruby method but I am looking f开发者_Python百科or details about what happens when you call @object.save.
http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-save
save
is a Rails method defined within theActiveRecord::Persistence
module. It saves the model. If the model is new, a record gets created in the database, otherwise the existing record gets updated.By default,
save
always run validations. If any of them fail the action is cancelled andsave
returns false. However, if you supply:validate => false
, validations are bypassed altogether.There’s a series of callbacks associated with the
save
method. If any of thebefore_*
callbacks return false the action is cancelled andsave
returns false.The
save!
(bang) method always runs validations but raises anActiveRecord::RecordInvalid
exception upon validation failure.
精彩评论