R
R
Roman Volkov2015-05-30 18:57:27
css
Roman Volkov, 2015-05-30 18:57:27

How to create multiple filters in rails?

There is a model, it has fields: name and category. How to arrange filters so that they do not overlap each other, but work together?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
inkShio, 2018-07-23
@Hardjuice

https://codepen.io/inkshio/pen/mjmbrM - you can do something like that

M
Maxim Timofeev, 2018-07-23
@webinar

https://codepen.io/inteia/pen/fDjcg

4
4itosik, 2015-06-01
@white_wolf_17

add to where(:name => params[:name], :category => params[:category]), or
@models = @models.where(:name => params[:name]) if params[:name] .present?
@models = @models.where(:category => params[:category]) if params[:category].present?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question