V
V
vdv_lg2014-09-09 00:07:18
Ruby on Rails
vdv_lg, 2014-09-09 00:07:18

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

2 answer(s)
S
Sergey Krasnodemsky, 2014-09-09
@Prognosticator

Create a method on the Product model.
The article is bookmarked.

V
vsuhachev, 2014-09-09
@vsuhachev

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 question

Ask a Question

731 491 924 answers to any question