rails restful select_tag with :on_change
- by Sam
So I'm finally starting to use rest in rails.
I want to have a select_tag with product categories and when one of the categories is selected I want it to update the products on change.
I did this before with
<% form_for :category, :url => { :action => "show" } do |f| %>
<%= select_tag :id, options_from_collection_for_select(Category.find(:all), :id, :name),
{ :onchange => "this.form.submit();"} %>
<% end %>
however now it doesn't work because it tries to do the show action.
I have two controllers
1) products
2) product_categories
products belongs_to product_categories with a has_many
How should I do this.
Since the products are listed on the products controller and index action should I use the products controller or should I use the product_categories controller to find the category such as in the show action and then render the product/index page.
But the real problem I have is how to get this form or any other option to work with restful routes.