Creating a Rails query from a hash of user input
Posted
by
Jamie
on Stack Overflow
See other posts from Stack Overflow
or by Jamie
Published on 2014-06-10T09:26:36Z
Indexed on
2014/06/12
15:25 UTC
Read the original article
Hit count: 344
I'm attempting to create a fairly complex search engine for a project using a variable number of search criteria. The user input is sorted into an array of hashes. The hashes contain the following information:
{
:column => "",
:value => "",
:operator => "", # Such as: =, !=, <, >, etc.
:and_or => "", # Two possible values: "and" and "or"
}
How can I loop through this array and use the information in these hashes to make an ActiveRecord WHERE query?
© Stack Overflow or respective owner