0

I'm trying to write a Rails 2.1 query (I know that I should upgrade, but that's not my decision at the moment) which using the 'IN' condition. It doesn't seem to work as expected.

It only takes into consideration the roles_id = 21 based on the below query and it doesn't consider both the roles_id(i.e., 21 and 31) to display the correct count.

Admin.find(:all, :conditions => ["test_column1 = ? and roles_id IN (?) and test_column2 = ?",234, '21,31', 1]).count 

How can I get this right?

1 Answer 1

1

You need to pass an array I think

Admin.find(:all, :conditions => ["test_column1 = ? and roles_id IN (?) and test_column2 = ?",234, [21,31], 1]).count 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.