collection_select not working as expected
Posted
by kgb
on Stack Overflow
See other posts from Stack Overflow
or by kgb
Published on 2010-03-30T19:30:31Z
Indexed on
2010/03/30
19:33 UTC
Read the original article
Hit count: 285
ruby-on-rails
First time I've come to use collection_select in a project and I've hit a wall with it.
A Profile has_one Team, Team has_many Profile.
In my view for editing profiles I have this.
<td><%= f.collection_select(:team_id, @team, :id, :title) %></td>
Which populates the drop down with titles of teams as expected. The couple of examples I have read seem to use it in a very similar way.
I can't figure out when the profile is saved why it isn't populating the team_id field in my DB. In the development log the team_id is being passed.
Processing ProfilesController#update (for 127.0.0.1 at 2010-03-28 22:49:16) [PUT] Parameters: {"commit"=>"Update", "profile"=>{"dob(1i)"=>"2010", "second_name"=>"", "dob(2i)"=>"3", "role"=>"", "dob(3i)"=>"28", "project"=>"", "specialties"=>"", "about"=>"", "team_id"=>"1", "status"=>"", "first_name"=>""}, "authenticity_token"=>"sdTiFPGj9JCO3OEge5EGNGxZbQSsq9ME5LP342EBjyc=", "id"=>"3"}
The update controller is the standard scaffold one, this has worked fine for all other additions to the profile model I'd made previously. Am I missing something obvious?
© Stack Overflow or respective owner