I am working on a Ruby on Rails project and using the Simple Form gem for my forms. I have a form where I need to change the collection of a select field based on the user's previous answer to another field.
For example, if the user selects "Category A" in the first field, the second field should show options only related to "Category A" and if the user selects "Category B", the second field should show options only related to "Category B".
How can I achieve this functionality using Ruby on Rails and Simple Form gem?
<% if @property.ubicacion == 'Panama' %>
<div class="col-md-4"><%= f.input :localizacion, collection: ['Costa del Este' ] %></div>
<% elsif @property.ubicacion == 'Playas'%>
<div class="col-md-4"><%= f.input :localizacion, collection: ['Corronado' ] %></div>
<% else %>
<div class="col-md-4"><%= f.input :localizacion, collection: ['' ] %></div>
<% end %>