Robert Jones
2005-Jul-19 11:51 UTC
will update_attributes ever handle associated objects automatically?
Apologies for the repetition in different language of a request I made on the comp.lang.ruby newsgroup. ActiveRecord::Base method "update_attributes" takes parameter "attributes" - a hash like {"name"=>"value",....} and updates the object accordingly, ie it finds the record in the table that the object refers to, and runs an update query. What I would like update_attributes to do is to deal with the updating of associated objects. I imagine that the parameter would then look something like {"name"=>"value",...., "child_object"=>{324=>{"name"=>"value",....}}, "many_objects"=>{12=>{"name"=>"value",....},15=>{"name"=>"value",..}},.. } where the "child_object" is an object associated via a belongs_to or has_one relationship, and the hash of "many_related_objects" is a collection of objects associated via a has_many relationship. update_attributes would then do the right thing with all of this - find all the related records in other tables and update them. Without this the ORM feels distinctly lacking to me. BTW, I love Ruby on Rails! I''m transferring my project "FreeMIS" from PHP/MySql to RoR, and keep getting those "I can''t believe I just did that so quickly" moments :) -- Robert Jones FreeMIS - http://project.freemis.net