Ruby on Rails - Railscasts PRO #88 Dynamic Select Menus (revised)
Why Stack Overflow recommends it
Stack Overflow users link it when someone needs dependent or cascading dropdowns in Rails, such as filtering cities, models or departments by a previous selection.
Recommended by 3 people across 3 different months, 2015 to 2018.
What it is
A short Railscasts PRO episode (revised #88) showing how to update one select menu based on the value of another in a Rails app. The example filters states/provinces by the chosen country using grouped options and a small amount of CoffeeScript.
What people said
Recommends shriyog · 2015-05 · Stack Overflow · on “Rails - dynamically change options in forms”
Just refer this railscast episode #88 [LINK] they have built dynamic select menus starting from scratch! Or better watch this revised #88 episode [this video] on Youtube. Follow the steps.You will get it.
Recommends Nezir · 2018-09 · Stack Overflow · on “List unique values from collection”
@IonãMatheus okay, I dont have time to write for you the sample of code but this will be more profitable to you: check this video and I hope you will get example how to filter cities: [this video] or the other videos on this specific topic [LINK]
Recommends John Cowan · 2018-10 · Stack Overflow · on “Rails and JQuery Select Drop-Down - How to Retain Selected Value”
I went with a different way, though it still using JQuery and populating one drop-down based on the selection of another. I found this Rails Cast: [this video] Seems to work for me. I did need to create a new table/model for my departments. But it is working.
Cites khush · 2016-04 · Stack Overflow · on “Ruby on Rails - grouped_collection_select error”
I am learning Ruby on Rails and still unfamilar with some of parts of the language. Using the grouped_collection_select I am trying to filter all the relevant models for a specific make of car... I am unsure if the grouped_collection_select has the correct parameters and if they are in the correct order as I encounter this error and cannot seem to resolve it : "undefined method `map' for "3 Series":String". Also I am using this railscast [this video] and already have the Javascript added to the relevant file. app\views_multi_search.html.erb <%= select_tag ('make_id'), options_from_collection_for_select(@makes, :id, :makes_info, 0 ), :prompt => "Select a Make" %> <%#= select_tag ('model_id'), opti
Cites user1175969 · 2016-07 · Stack Overflow · on “Filter options in a select_tag based on option selected in the previous select_tag (with a HABTM relationship)”
I have 2 select_tag dropdowns in a form_tag . The first dropdown is for X and the second is for Y. X and Y have a has_and_belongs_to_many association. <%= select_tag 'x_id', options_for_select(@xs.collect{ |u| [u.name, u.id] }) %> <%= select_tag 'y_id', options_for_select(@ys.collect{ |u| [u.code + ": " + u.name, u.id] }) %> Now, I want the options in the second dropdown to get filtered based on the option selected in the first dropdown. I have the Railscast [this video] for dynamic select menus, but it explains how to do it in a form_for . How do I do it in a form_tag ?