I have a page that allows the user to select the filters to run a query and then show the results for the given results but keeping the selected filters to allow the user to see them and adjust them and run the query again
The filters are shown in the index view and the results in a results view.
To implement this I have a controller with two methods index and results.
Since both views need to show the filters I implemented a partial called _filters and both the index and the results render the filters like this.
<%= render 'filters' %>
And the filters view puts together a HTML select like this
<select id="centro_de_costos" name="centro_de_costos" class="small-12">
<% @cost_centers.each do |cost_center| %>
<option value="<%= cost_center['name'] %>"><%= cost_center['name'] %></option>
<% end %>
</select>
Both the index method and the results methods of the controller have exactly the logic to obtain the list of @cost_centers, but what is weird is that this works for the index view but not when i show the results view.
The index is showing a HTML select control with the cost_centers but in the results is a select without any options
I have debugged and I can see the that the cost_centers are both being returned correctly for both the index and the results
What can be causing this and how can I solve it.
Aucun commentaire:
Enregistrer un commentaire