I want to search a table with multiple conditions in Rails. I am using Active record and rails version 3.1.0.
I have Movies object, and want to achieve the equivalent of the following in rails:
Select * from Movies where rating = 'R' OR rating = 'PG'
I tried the following but it does not work
@filtered = Movies.find(:all, :conditions => { :rating => 'R', :rating => 'PG' })
Can you please provide help to write an equivalent of SQL query mentioned above.
One way would be to build an "IN" condition with:
@filtered = Movie.where(:rating => ['R', 'PG']).all
EDIT: I changed your class to "Movie" from "Movies". I assume that's what you will want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With