Perhaps off topic -- I've got an unreleased gem that patches save() and create() in ActiveRecord so that you can skip callbacks (and validations, although I know you can already do that). You'd do something like obj.save(:skip_callbacks => true, :skip_validations => true).
Is there a reason this behaviour is absent from ActiveRecord? Would people welcome it if I submitted a pull request with this feature? On 14 June 2012 10:17, Xavier Noria <[email protected]> wrote: > There is some bit of history here. > > The purpose of update_attribute was to be able to touch an attribute fast, > set a flag for example... something you know can go straight to the > database. Indeed, update_attribute has *never* run validations. > > There was some discussion about this method for Rails 3 because if the > goal was to bypass stuff to be fast it didn't felt consistent to still go > through the callbacks. And for some time update_attribute skipped also > callbacks in edge: > > > https://github.com/rails/rails/commit/01629d180468049d17a8be6900e27a4f0d2b18c4 > > though it still touched updated_at, so fast but not quite there. > > That method is so popular, however, that the change felt too risky because > it was subtle, and that was reverted just before shipping: > > > https://github.com/rails/rails/commit/30ea923040ded944209c98383389b6c9aafe806a > > In the end, in 3.1 it was decided to introduce instead a new method > update_column. That is the fast one. > > Given the current status of things, I personally agree that running > validations in update_attribute in Rails 4 would be a good idea. > > Let's see what other core team members think though. Thoughts? > > > -- > 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. > -- 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.
