PROBLEM:
I want to run a query which would trigger something like
select * from users where code in (1,2,4);
using a named_scope
.
WHAT I TRIED:
This is for a single code:
named_scope :of_code, lambda {|code| {:conditions => ["code = ?", code]}}
I tried something like
named_scope :of_codes, lambda {|codes| {:conditions => ["code in ?", codes]}}
and sent
user.of_codes('(1,2,4)')
it triggers
select * from users where code in '(1,2,4)'
which raises a MySQL error because of the extra quotes.
PS: Ideally I would like to send user.of_codes([1,2,4])