Hi,
I try to create a select menu with all the city available in my shop
form. I've been able to populate the select menu but the city_id isn't
stored in the shop table. There must be an error in my view regarding
that i'm not sure to understand each parameters of the
collection_select.


Shop.rb
class Shop < ActiveRecord::Base
  attr_accessible :total_visit, :friends_invited

  has_and_belongs_to_many :products
  has_and_belongs_to_many :owners
  has_many :credits
  has_many :visits
  belongs_to :city
end


City.rb
class City < ActiveRecord::Base
  attr_accessible :name, :continent

  has_one :shop
end

Shop view
<% form_for @shop do |f| %>
  <p>
    <%= collection_select(@shop,:city_id, City.find(:all), :id, :name,
options ={:prompt => "-Select a city"}, :class =>"") %>
  </p>
  <p><%= f.submit "Submit" %></p>
<% end %>



Best,
Greg
-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to