Creating a Rails query from a hash of user input
- by Jamie
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?