Saving without validation rails 3
save(:validate => false)
eg:
object.save(:validate => false)
I think in your use case where you want to save a subset of attributes you still presumably want to do validation for the attributes that you are saving. Remember that all attributes that are selected into the ActiveRecord object that you are saving/updating get updated in the database. Thus, to save a single attribute you would do:
update_attributes updates all the attributes so the validation will apply for that.but if u use update_attribute only that field get updated and other fields are intact.
# Skipping validation for subject
Post.find(1, :select => "id, subject").update_attribute(:subject, "foobar")
# With validation for subject
Post.find(1, :select => "id, subject").update_attributes(:subject => "foobar')
No comments:
Post a Comment