I have a Categ model, which I want to associate with my Listing model. In the _form.html.erb I have added this:
<%= f.label :category %><br> <%= f.collection_select(:categ_id, @categs, :id, :name) %>
In the listings_controller.rb
before_filter :prepare_categs def create @listing = Listing.new(listing_params) @listing.categ_id = :categ_id .... private def prepare_categs @categs = Categ.all end
This @listing.categ_id = :categ_id doesn't work. I can chose the category but not saving. Any idea what could be wrong? How can I refer the selection of a drop-down menu list in the controller?
Thank you, Szabolcs