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 <[email protected]> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> 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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.