forked from mislav/will_paginate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bring back old named_scope_patch.rb and delete version-specific ones
- Loading branch information
Showing
3 changed files
with
37 additions
and
78 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
ActiveRecord::Associations::AssociationProxy.class_eval do | ||
protected | ||
def with_scope(*args, &block) | ||
@reflection.klass.send :with_scope, *args, &block | ||
end | ||
end | ||
|
||
[ ActiveRecord::Associations::AssociationCollection, | ||
ActiveRecord::Associations::HasManyThroughAssociation ].each do |klass| | ||
klass.class_eval do | ||
protected | ||
alias :method_missing_without_scopes :method_missing_without_paginate | ||
def method_missing_without_paginate(method, *args, &block) | ||
if @reflection.klass.scopes.include?(method) | ||
@reflection.klass.scopes[method].call(self, *args, &block) | ||
else | ||
method_missing_without_scopes(method, *args, &block) | ||
end | ||
end | ||
end | ||
end | ||
|
||
# Rails 1.2.6 | ||
ActiveRecord::Associations::HasAndBelongsToManyAssociation.class_eval do | ||
protected | ||
def method_missing(method, *args, &block) | ||
if @target.respond_to?(method) || (!@reflection.klass.respond_to?(method) && Class.respond_to?(method)) | ||
super | ||
elsif @reflection.klass.scopes.include?(method) | ||
@reflection.klass.scopes[method].call(self, *args) | ||
else | ||
@reflection.klass.with_scope(:find => { :conditions => @finder_sql, :joins => @join_sql, :readonly => false }) do | ||
@reflection.klass.send(method, *args, &block) | ||
end | ||
end | ||
end | ||
end if ActiveRecord::Base.respond_to? :find_first |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.