Reputation: 599
I have
scope :delivered, where(:status => Status::DELIVERED)
SELECT "orders".* FROM "orders" WHERE "orders"."status" IN ('Pending', 'Partially Prepared')
Now I want to add new scope to get all except delivered orders.
scope :not_delivered, where(:status != Status::DELIVERED)
SELECT "orders".* FROM "orders" WHERE ('t')
How to get a reverse scope?
Upvotes: 2
Views: 928
Reputation: 12255
You have to use a string condition. scope :not_delivered, where('status NOT ?', Status::DELIVERED)
.
Not confident about the syntax, I don't do SQL often. But you should get the idea.
Upvotes: 2