From: Brian Candler Date: 2010-09-30T04:13:21+09:00 Subject: Re: ActiveRecord Mixing Conditions + Better Way to Write This Ken Ghosh wrote: > I manage to get desired code but doesn't seem to be happy with clarity > of it > > Account.first.websites.last.users.find(:all,:conditions => ["country = ? > AND status = ? AND admin IS NULL OR admin = ?","XYZ","Single","false"]) Beware relative precedence of AND and OR. It's possible AND binds more tightly than OR, I'm not sure. So to be safe: ["country = ? AND status = ? AND (admin IS NULL or admin=?)", ...] If you are using Rails 3, then look at the new syntax which Active Relation gives you. Google "rails 3 arel" -- Posted via http://www.ruby-forum.com/.