Hey All,
I'm trying to play along w/the 'complex forms 1' railscast (#73 Complex Forms Part 1 - RailsCasts) and having trouble. The view is projects/new. I'm trying to add some project_people to the form w/code like so:
<% form_for(@project) do |f| %>
[project stuff here]
<% for pp in @project.project_person %> <% fields_for 'project[proj_people_attributes]', pp do |pp_form| %> <p> Person: <%= collection_select(:pp, :person_id, Person.get_list, :id, :nom, {:prompt => 'Person?'}) %> Role: <%= select(:pp, :role, Person::ROLE_NAMES, {:prompt => 'Role?'}) %> </p> <% end %> <% end %>
<% end %>
I get the expected series of 3 <select>s, but their names are not automatically indexed. So I get:
<select id="pp_person_id" name="pp[person_id]"> <select id="pp_role" name="pp[role] ">
Rather than this:
<select id="pp_person_id" name="project[proj_people_attributes][1][person_id]"> <select id="pp_role" name="project[proj_people_attributes][1][role] ">
(At least I *think* that's what they should be.)
Now, you may be saying to yourself "he's got to call those select helpers on the pp_form object that the fields_for block yields." If I do that, I get (e.g.): undefined method `merge' for :nom:Symbol. So are there different select helpers for using inside fields_for?
Many thanks!
-Roy
Roy Pardee Research Analyst/Programmer Group Health Center For Health Studies (Cancer Research Network) (206) 287-2078 Google Talk: rpardee