Rails soothing filtration

I have an action with an index, and I would like the user to be able to filter the results on the index page by clicking on the "filter links" on the same page.

There is a beautiful rails that allows you to filter the results by typing in the search box.

I would like to filter the results based on the links that the user clicks. How can i do this? Is there a way to pass parameters to the controller using link_to?

for example, on a sheet of books with an index page, I would like to display the following link

<%= link_to "Fiction", books_path %>

and clicking on the link will only display books in the fiction category.

+3
source share
1 answer

link_to "link_to :"

, , , ( , ):

<%= link_to "Fiction", books_path(:category => "fiction") %>
+1

Source: https://habr.com/ru/post/1731968/


All Articles