> I've been looking for a while and I can't find a way to compose an > activerecord .where query that excludes certain ranges / values. > > Like User.where(:id !=> [3,9,23], :active => 1)
User.where(["active = 1 AND id NOT IN (?)", [3,9,23]]) If it were me, I'd create a scope on User named 'active' so you could do... User.active.where(["id NOT IN (?)", [3,9,23]]) You could even create a "not_in" scope if you wanted to, but that might be going a little too far... -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.