I am trying to pass both a field and a value in a find call:
@employee = Employee.find(:all,
:conditions => [ '? = ?', params[:key], params[:value].to_i)
Output signal
SELECT * FROM `employees` WHERE ('is_manager' = 1)
This does not return any results, however, when I try to execute it directly in mysqsl using the same call without `` around is_manager, it works fine. How to convert the value of params [: key] to a character so that the resulting SQL query looks like this:
SELECT * FROM `employees` WHERE (is_manager = 1)
Thanks D
source
share