My apologies for the necro-post, just wanted to express one concern with the solution proposed here.
If attr_protected is in use for the attribute in question, `update_attributes :attr => val` won't function just as if we used the singular update_attribute. Obviously this is not a huge issue as we could just do something like `model.attr = val \ model.save`, but that's a bit chunky. It would be nice to have a way to use `update_attribute` WITH validations. I wouldn't propose, nor agree with, changing the default behavior of `update_attribute` at this stage. I'm just saying it would be nice to have validations as an option for that method, or at least another method that could update a single protected attribute with validations. Thanks for listening. On Mar 3, 12:29 pm, "DHH" <[EMAIL PROTECTED]> wrote: > > I was hoping someone could take the time to explain to me why > > update_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 automatic > functions that update a flag or increment a counter at billing. These > functions should not fail just because the object is invalid for > whatever reason. > > If you want the same functionality with validation, you can use > update_attributes :attribute => value. > > If this is confusion, please do add a documentation patch explaining > it fully. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
