I have my rails app, which is filled with products, set up with a very basic search controller and index that basically search the db and renders the results. One of the ways a user can search is by category. So for eg, a user will enter a category, eg: 12345 and every product that matches this category will be returned.
How can I set up a link to the category in the products index, that when clicked will perform the category search and return all products which share the clicked category? For example, we have product A with category 4567. I was 4567 to be a link to the controller search action which search and returns all products that match 4567, and I need this to be done for each product (about 60k). Sorry if this isn’t clear, and please ask if there is anything that needs clarification.
Assuming that your SearchController is something like this:
In your product index view, you could do something like: