0

I have this query that works but I would like to expand it so that I can check for multiple ids such that I pass in a vector of ids. [1,2,3,5] etc... I have tried using SQL IN with no luck.

EventType.find(3).events.all(:include => {:sheet => :rink}, :conditions => ["rinks.id = ?", 2])

1 Answer 1

1

You were on the right track with IN. Here's syntax that will work in Rails 3+:

EventType.find(3).events.where("id IN (?)", [1,2,3]).include(:sheet => :rink)

Improvement from a comment removes SQL entirely:

EventType.find(3).events.where(:id => [1,2,3]).include(:sheet => :rink)
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, I was missing the parenthesis around ?
You could also where(:id => [1,2,3])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.