I have looked at a whole bunch of solutions for this and maybe I am just dense, but I can't get anything to work. These are the two selects I am trying to tie together in a product/new view that will allow the user to select a category of product and then constrain the subcategory listing:
<p>
<%= f.label :category_id %>:
<%= f.select("category", Category.find(:all).collect {|c|[c.name, c.id]})%>
</p>
<p>
<%= f.label :subcategory_id %>:
<%= f.select("subcategory", Subcategory.find(:all).collect {|s|[s.name, s.id]})%>
</p>
I have a function in my subcategory controller to get the information from the database:
def get_subcategories
@subcategories = Subcategory.find_by_category_id(:all)
end
But I can't figure out how to wire it together, and it seems like it should be easy in RoR.