Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

ActiveRecord::Relation#except and #only loses scope extensions #231

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Contributor

iain commented Mar 19, 2011

Repeating what I've said in Lighthouse ticket 6598

Given a scope with extensions
When I use the except to remove a part from the relation
Then the extensions are gone, because except returns a brand new relation object.

This means the following doesn't work (when using Kaminari, which uses extensions):

Post.page(2).except(:order).current_page

Because the current_page method was added by the page scope.

This issue is present in at least 3.0.5 and master.

The supplied patch will apply the extensions again after using except and only.

There is some duplication going on in both methods. A private method could certainly be extracted (although I'm clueless on a name).

Owner

tenderlove commented Mar 21, 2011

Merged. Thank you!

@tenderlove tenderlove closed this Mar 21, 2011

@hisas hisas pushed a commit to hisas/rails that referenced this pull request May 9, 2017

@mikel mikel Merged pull request #231 from dasch/improve-readme.
Improve README
598a85b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment