Sorry to cross post from Rails ML but I did not get any response, and this is really bugging me...

---------- Forwarded message ----------
From: Daniel N < [EMAIL PROTECTED]>
Date: Sep 30, 2006 11:08 PM
Subject: update_attribute does not validate?
To: [EMAIL PROTECTED]

While using the in place editor, I noticed that none of my validations were firing.  Digging around in the docs I found that this is deliberate. 

http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M000909

This method is overwritten by the Validation module that'll make sure that updates made with this method doesn't get subjected to validation checks. Hence, attributes can be updated even if the full object isn't valid.

In the validations module,

alias_method_chain :update_attribute, :validation_skipping
# Updates a single attribute and saves the record without going through the normal validation procedure.
# This is especially useful for boolean flags on existing records. The regular +update_attribute+ method

# in Base is replaced with this when the validations module is mixed in, which it is by default.
def update_attribute_with_validation_skipping(name, value)
send(name.to_s + '=', value)
save(false)

end
 Why would validations be turned off by default when using in place editors? and also why would update_attribute have validation turned off by default with no apparent way of turning it back on?

Can anyone explain this to me please.

Cheers


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/rubyonrails-core
-~----------~----~----~----~------~----~------~--~---

Reply via email to