There is a block syntax for new and create, which looks like this:
user = User.create do |u| u.name = "David" u.mail = " dhh@rails.com " end
Is there a block syntax that will be valid in Rails 3 and Rails 4 for updating attributes? Sort of:
user = User.where(name: "David").first user.update_attributes do |u| u.mail = " dhh@rubyonrails.com " end
Maybe not update_attributes , but something like that. I searched the web and the source for Rails 4 on Github, and I think this is not happening. I am wrong?
PS I'm not looking for any methods for patch monkeys or something like that, just wondering if there is a method that comes with ActiveRecord .
source share