Skip to main content

How do I do multiparameter filter

Rails • Asked by Jaroslav Horák

Hi,
I have some sort of e-shop. I have Category model and Product model. Product has some parameters like color, material, price etc.
My question is what approach to use to filter by these parameters and categories.
Best way to include url too to be SEO friendly. Example:
www.example.com/category/subcategory/color/material?priceFrom=100&priceTo=1000
Is there some gem? Or what do you use?


Not sure how you'd get this into a URL, but a very common gem I see for operations like this is ransack:

https://github.com/activerecord-hackery/ransack

It generates a SQL query based on whatever the user puts in. It's very fast, but the one drawback is it only works with your database columns.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 22,346+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.