I sometimes need to update attributes in mass after initialization without having to save the record (what #update_attributes does). This doesn't seem to be possible in any nice way right now. For example, @obj.attributes.merge!(:field => 'new text') doesn't stick.
I've been experimenting with this method and it seems to do the trick:
module ActiveRecord class Base def merge_attributes!(attributes = {}) attributes.each_pair do |att, value| self.send("#{att}=", value) if self.respond_to?("#{att}=") end self.attributes end end end
Anyone else find that useful? Or harmful? If it makes sense to others ill patch it up.