In the index action of my Users controller, I am able to capture all users belonging to the same city as the current_user
in an ActiveRecord::Relation object @users
. In my view I am able to iterate through @users
and display the results. What I'd like to do is give the current_user
further options to filter the results. I want to add a form and filter button in the view, which will allow the current_user to select filters, such as:
- Minimum Age and Maximum Age (Drop Down)
- Religion (Drop down of checkboxes)
- Diet (Drop down of checkboxes)
- And so on.
Once the current_user makes the selections and clicks on filter, the results will be filtered based on the criteria selected. I want to know how to build a query to do this?