On Mar 12, 2014, at 7:23 AM, Anh Nguyen <khac...@gmail.com> wrote: > POLA http://en.wikipedia.org/wiki/Principle_of_least_astonishment > > Examples > > ``` > # user.rb > class User < ActiveRecord::Base > attr_accessible :name, :username > validates :username, uniqueness: true > end > > user1 = User.create(name: 'Name 1', username: 'username1') > user2 = User.create(name: 'Name 2', username: 'username2') > > user1.username = 'username2' > user1.save # => false > user1.update_attribute(name: 'New Name') > user1.reload > > user1.username # => 'username2' > # update_attribute is expected to update the specified attribute, not other > ones. Thus it is violating POLA > ```
This behavior was exactly why update_attribute was (briefly) deprecated in 3.2.7: https://groups.google.com/forum/?hl=en&fromgroups#!topic/rubyonrails-core/BWPUTK7WvYA Not sure how it got un-deprecated... --Matt Jones -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.