dimanche 27 mars 2016

How to write active record with and and or conditions in ruby

i want to write active record with 3 and condition(must) and two or conditions i have written like this.

@properties=Property.where(category_id: 2).where(status: 3).where(p_type: 'sell')

this lists me the query with and conditions true , here i need to include two or conditions at end, how to do so?, it tried like this but gives error

@properties=Property.where(category_id: 2).where(status: 3).where(p_type: 'sell').or(location: @location).or(featured: '1)

Please help. Any help is appreciatable

Aucun commentaire:

Enregistrer un commentaire