[LRUG] Nested form params/active records

Joel Chippindale joel.chippindale at gmail.com
Fri Feb 22 05:22:57 PST 2008


Given an ActiveRecord A, that belongs_to a B, I can create a single form to
edit all the attributes of these nested records in one go, leading to a
params hash with structure like:

{"a" => {"an_attribute_of_a" => "x", "b" => { "an_attribute_of_b" => "y",
"another_attribute_of_b" => "z" } }
Then I would like to be able to write the following code, where a (is an
instance of A) that belongs to b (an instance of B)

a.update_attributes(params[:a])

and have it update the attributes of a AND also b which it belongs to.

Before I go reinventing the wheel, does anyone know of an existing plugin
for ActiveRecord will enable this?

J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20080222/3754ff0e/attachment-0003.html>


More information about the Chat mailing list