George,

You may want to give
http://github.com/snusnu/dm-accepts_nested_attributes a try. It should
take care of the DM side of things. I'm not entirely sure how merb's
#field_for plays with it atm, but I'd be glad to work with you (and
accept patches :) to make merb(-helpers) and dana (short for
dm-accepts_nested_attributes) play together nicely.

cheers
snusnu

On Tue, Nov 17, 2009 at 11:10, George <[email protected]> wrote:
> If a Client model has-n addresses, what's the best way to handle these
> on a form?
>
> class Client
>  ...
>  has n, :client_addresses
>  has n, :addresses, :through => :client_addresses
>  ...
> end
>
> In a Client edit form we have something like this:
> <% client.addresses.each do |address| %>
> <div>
>  <%= fields_for address do %>
>    <%= text_field :address1, :label=>"Number/name" %>
>    <%= text_field :address2, :label=>"Locality" %>
>    ...etc...
>  <% end =%>
> </div>
> <% end %>
>
> That renders each html address field with names like "address
> [address1]" so I would expect the server side to receive those as
> arrays of 0-or-more values. Looking at the output it seems that merb
> only sees one value for each field.
> Is this the right approach? How should we handle the submitted address
> fields server side?
> I suppose I could parse the params object manually but that is not
> very reusable.
>
> Many thanks
> George
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "DataMapper" group.
> To post to this group, send email to [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/datamapper?hl=.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=.


Reply via email to