Reputation: 27748
Assuming I have a User
model
paged_users = User.scoped.limit(2).offset(3)
Is there a way to make paged_user
have User.scoped
by removing limit and offset? IE:
all_user = paged_users.remove_limit.remove_offset
Upvotes: 19
Views: 9246
Reputation: 107728
I'm thinking you have a scope like this:
users = User.where("something").limit(20).order("name ASC")
With this in mind...
To remove the limit
pass nil
to limit
:
users.limit(nil)
Then to remove the ordering, use reorder
, also passing it nil
:
users.limit(nil).reorder(nil)
That will remove both the limit and the order from your scope, preserving all other things. If you were to use unscoped
, it would remove all scoping.
Upvotes: 47