I do understand that the naming can be confusing, but it's pretty late in the game to be changing it. It's used as a way to skip validations even inside Rails itself, and changing the behavior of that method would have very far-reaching implications.
- Jamis On Mar 4, 2007, at 12:17 PM, eventualbuddha wrote:
I didn't know about this either, and I've read through AR almost in its entirety. The similar naming of the methods, to me, strongly implies that they have similar behavior and that the only difference is that one updates one attribute, the other updates any number of attributes. I'm curious as to whether anyone currently depends on update_attribute's lack of validation and, if so, how should we phase it into a validating method? One possible way to do it is that if validation fails, issue a warning stating that the implementation has changed and that if you want to update without validation to use attributes= and save(false). The problem with this, of course, is that people who expect update_attribute to validate will be receiving spurious warnings. Other suggestions? -bd On Mar 4, 8:51 am, "Peter Marklund" <[EMAIL PROTECTED]> wrote:On Mar 3, 11:29 am, "DHH" <[EMAIL PROTECTED]> wrote:I was hoping someone could take the time to explain to me whyupdate_attribute doesn't trigger validations? Why am I concerned with this?Because it's intended to be used in scenarios where you're not interested in dealing with validation errors. Such as automaticfunctions that update a flag or increment a counter at billing. Thesefunctions should not fail just because the object is invalid for whatever reason.I think things should be swapped around, the API should be designed for the common case which is that you want validation. If you don't want validation, then do object.attribute = value object.save(false)Of course, this is ultimately a matter of taste and of priorities, butI think in this case data integrity and the principle of least surprise should be prioritized.--~--~---------~--~----~------------~-------~--~----~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 rubyonrails-core- [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/ group/rubyonrails-core?hl=en-~----------~----~----~----~------~----~------~--~---
smime.p7s
Description: S/MIME cryptographic signature
