I currently have two Ruby selects: one for categories and the other one for subcategories. As you may anticipate, the second one has to update itself every time the first one changes.
For example, if I select from the first one the category “Sports”, the second select should load all the sports.
How can I handle that “index change” event? Is there a “ruby way” or I have to use javascript?
Thanks,
Brian
You have to use at least some JavaScript. In jQuery, you can do this:
In your CategoriesController, your show action should respond to format.js, which should render a subcategories partial:
and your subcategories partial: