I am trying to create an ‘OR’ sql statement in ActiveRecord 3, I tried all kinds of variations but can’t figure it out…
For example I want this query to include multiple ‘channel_ids’ and have it return all posts for any of the channel IDs. This works for one:
Post.where(:user => 'mike').where(:channel_id => 0).limit(20)
but I cant figure out how to do it with multiples, I’ve tried for example:
Post.where(:user => 'mike').where(:channel_id => ?, [0,1,2,3]).limit(20)
but it didn’t work. How can I make this work?
Use the Arel methods to do this: