Say I have a person object which has a aggregation object call
address. The the code to manipulate a form for create a new person
should be:
# new.rhtml
<% form_for :person, :url => {:action => ''create''} do
|f| %>
<%= render :partial => ''form'', :locals => {:f =>
form} %>
<%= submit_tag "Create" %>
<% end %>
# _form.rhtml
<p><label>Name</label><br/><%= form.text_field :name
%></p>
<p><label>Country</label><br/><%= form.text_field
:country %></p>
<p><label>City</label><br/><%= form.text_field :city
%></p>
This does work. But country and city belong to the aggregation object
address and I want to use address in the form. According to RDoc and
rails book. The above text_field helper method will generate <input
value="person[name]" /> and rails will recognize it and translate
it
into :person => {:name}. And if I can generate something like <input
value="person[address][country]" />, then rails will get :person
=>
{:address => {:country}}, which is exactly what I want. How can I tell
rails to generate this kind of input for me? I cannot find any
information about this in RDoc. Thanks a lot.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---