rails/rails — pull request #11599 by versioncontrol (2013-07-25 17:21:55+00:00)
Title: Update attributes with block

References issue #992

*Not sure why this was never integrated (or removed), but I think it has a valid use case*

ActiveRecord::Base#new and #create accepts both a Hash of attributes and a block:

``` ruby
User.create(:first_name => 'Jamie') do |u|
u.is_admin = false
end
```

This patch adds that same functionality to update_attributes:

``` ruby
user.update_attributes(:first_name => 'Jamie') do |u|
u.is_admin = false
end
user.first_name #=> 'Jamie'
user.is_admin #=> false
```

A use case for this is in the administration area, where authenticated users might be allowed to update attributes that are otherwise protected.