Created
May 31, 2012 21:38
-
-
Save tgildea/2846496 to your computer and use it in GitHub Desktop.
Monkey Patch to fix ActiveRecord Scope Caching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
raise "Check to see if #first and #last bug are fixed" if Rails::VERSION::STRING != "3.2.4" | |
module ActiveRecord | |
module Scoping | |
module Named | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def scoped(options = nil) | |
if options | |
scoped.apply_finder_options(options) | |
else | |
if current_scope | |
current_scope.clone | |
else | |
scope = relation.clone | |
scope.default_scoped = true | |
scope | |
end | |
end | |
end | |
def scope_attributes # :nodoc: | |
if current_scope | |
current_scope.scope_for_create | |
else | |
scope = relation.clone | |
scope.default_scoped = true | |
scope.scope_for_create | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment