I have these 2 models:

class User < ActiveRecord::Base
  has_one :city
  accepts_nested_attributes_for :city
end


class City < ActiveRecord::Base
  belongs_to :user
end

This view:

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

  <%= f.fields_for :city_attributes 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 %>

So, I already have a list of cities added. I want to allow the user to
select from one of the available cities in the select. But, when I
submit the form, I get this error:

Couldn't find City with ID=1 for User with ID=

What am I doing wrong?

-- 
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