Answer the question
In order to leave comments, you need to log in
How to make an online store product filter in RubyOnRails?
There is a Products controller. On the page you need to display, say, those products for which a certain column in scaffold has a certain value (tag == value). Do I need to create a separate method or is it enough to use each or select in the view? New to Ruby and Rails. Perhaps a very trivial question.
Answer the question
In order to leave comments, you need to log in
Create a method on the Product model.
The article is bookmarked.
You can write a filter yourself, for this you insert a form into index.html.erb that sends a GET request with filter values to the same address (products_path in your case).
Next, in the index method of the controller, analyze the parameters and if they come, then apply a filter to the selection
. You can also use ready-made solutions: ransack, has_scope, searchlight
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question