This project is archived and is in readonly mode.

#6598 ✓committed
iain

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

Reported by iain | March 19th, 2011 @ 09:35 PM | in 3.0.6

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).

Edit: GitHub pull request started working again: https://github.com/rails/rails/pull/231

Comments and changes to this ticket

  • 2kan

    2kan March 21st, 2011 @ 12:31 PM

    • Tag changed from activerecord, patch to rails edge, activerecord, patch
    • Assigned user set to “Aaron Patterson”
  • Aaron Patterson

    Aaron Patterson March 21st, 2011 @ 05:31 PM

    • State changed from “new” to “committed”
    • Milestone set to 3.0.6
    • Importance changed from “” to “Low”

    Merged. Thanks!

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Pages