You could always take the difference of two queries, if needed: User.all - User.where(:id => [1,2,3])
If your list of ids to exclude is not long, you can also use SQL in a where argument: User.where("id != ? and id != ?", 1, 2) Phil On Mon, Feb 14, 2011 at 3:19 PM, Shea Barton <li...@ruby-forum.com> wrote: > 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) > > help? > > -- > Posted via http://www.ruby-forum.com/. > > -- > 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. > > -- 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.