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 datamap...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=.


Reply via email to