Hello, I have Category and a Product models. I want for each product to belong to a category. How would I have a drop down list so that you can select a category from the product pages?
I've gotten everything to work with this:
<%= collection_select(:category, :id, @categories, :id, :title, options ={:prompt => "-Select a category"}, :class =>"category") %>
and using
@product.category_id = params[:category][:id]
in my update/create controller methods
but it feels clunky and it does not "read" the value from the @product
when editing and I have no idea how to make it so that it does. Am I doing something wrong?