If I try to pass an User instance, the select isn't displayed. Here's 
the view now:

<%= form_for @user,:url => users_path,:method => :post do |f| %>


  <%= f.fields_for :city do |b| %>
  <%= b.collection_select :id,City.all,:id,:name %>
  <% end %>

  <div class="field">
    <%= f.label :name %><br />
    <%= f.text_field :name %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

I guess it's expecting me to build the city instance in the controller? 
The way I got it to work is by doing this in my model:

def city_attributes=(attribs)
  self.city = City.find(attribs[:id])
end

Is there no other way?

-- 
Posted via http://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.

Reply via email to