aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorAkira Matsuda <ronnie@dio.jp>2016-01-28 17:13:47 +0900
committerAkira Matsuda <ronnie@dio.jp>2016-01-28 18:37:39 +0900
commitdc925119a3912ecfe0df400007163f33b99d6385 (patch)
treeb43c5b89f30504ac028b62bdde9f638b1775fbff /activerecord/lib
parenta69281614a7ed6c134d9a799419dd34dd5293a81 (diff)
downloadrails-dc925119a3912ecfe0df400007163f33b99d6385.tar.gz
rails-dc925119a3912ecfe0df400007163f33b99d6385.tar.bz2
rails-dc925119a3912ecfe0df400007163f33b99d6385.zip
Revert "Remove valid_scope_name? check - use ruby"
This reverts commit f6db31ec16e42ee7713029f7120f0b011d1ddc6c. Reason: Scope names can very easily conflict, particularly when sharing Concerns within the team, or using multiple gems that extend AR models. It is true that Ruby has the ability to detect this with the -w option, but the reality is that we are depending on too many gems that do not care about Ruby warnings, therefore it might not be a realistic solution to turn this switch on in our real-world apps.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/scoping/named.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/scoping/named.rb b/activerecord/lib/active_record/scoping/named.rb
index 103569c84d..5395bd6076 100644
--- a/activerecord/lib/active_record/scoping/named.rb
+++ b/activerecord/lib/active_record/scoping/named.rb
@@ -151,6 +151,7 @@ module ActiveRecord
"a class method with the same name."
end
+ valid_scope_name?(name)
extension = Module.new(&block) if block
if body.respond_to?(:to_proc)
@@ -169,6 +170,15 @@ module ActiveRecord
end
end
end
+
+ protected
+
+ def valid_scope_name?(name)
+ if respond_to?(name, true)
+ logger.warn "Creating scope :#{name}. " \
+ "Overwriting existing method #{self.name}.#{name}."
+ end
+ end
end
end
end