On Apr 7, 1:37 pm, John Catalyne <li...@ruby-forum.com> wrote: > Ignore the model names and what they stand for :). They are only for > example purpose. > > So, if I make my view like this: > > <%= form_for :user,:url => users_path,:method => :post do |f| %> >
Oh, for nested attributes to work you need an actual instance of user, not the symbol :user > <%= f.fields_for :city do |b| %> > <%= b.collection_select :id,City.all,:id,:name %> > <% end %> I'm not convinced that this will play well with nested attributes. nested attributes mostly wants to either create a new object or edit an existing one, whereas you want to choose from a list of objects and then edit one of those (to set the user_id) Fred > > <div class="field"> > <%= f.label :name %><br /> > <%= f.text_field :name %> > </div> > <div class="actions"> > <%= f.submit %> > </div> > <% end %> > > Then I get the association mismatch: > > City(#37602432) expected, got > ActiveSupport::HashWithIndifferentAccess(#32969988) > > With these parameters: > > {"commit"=>"Save User", > "authenticity_token"=>"whatever", > "utf8"=>"✓", > "user"=>{"city"=>{"id"=>"1"}, > "name"=>"as"}} > > -- > Posted viahttp://www.ruby-forum.com/. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.