diff options
author | Matthew Rudy Jacobs <matthewrudyjacobs@gmail.com> | 2010-03-02 11:24:35 +0800 |
---|---|---|
committer | wycats <wycats@gmail.com> | 2010-03-28 13:53:20 -0700 |
commit | b0967cc5cf5ce08e7fb0574692e3bb785e79973a (patch) | |
tree | 788b462e1bbbd198e7251e3f69637625d5ddbbe3 /activerecord/lib | |
parent | 77a2a3d9b3aa461437ced326ea4a70112a8c68ed (diff) | |
download | rails-b0967cc5cf5ce08e7fb0574692e3bb785e79973a.tar.gz rails-b0967cc5cf5ce08e7fb0574692e3bb785e79973a.tar.bz2 rails-b0967cc5cf5ce08e7fb0574692e3bb785e79973a.zip |
defining a named_scope which overwrites an existing method is now allowed we just log a warning.
This was motivated by the fact that :open is defined on all classes
as such the named_scope "open" can never be used, without hacking
ActiveRecord with an "undef_method" [#4083 state:resolved]
Signed-off-by: wycats <wycats@gmail.com>
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/named_scope.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb index 11c21a9207..aac00cc54a 100644 --- a/activerecord/lib/active_record/named_scope.rb +++ b/activerecord/lib/active_record/named_scope.rb @@ -102,7 +102,8 @@ module ActiveRecord name = name.to_sym if !scopes[name] && respond_to?(name, true) - raise ArgumentError, "Cannot define scope :#{name} because #{self.name}.#{name} method already exists." + logger.warn "Creating scope :#{name}. " \ + "Overwriting existing method #{self.name}.#{name}." end scopes[name] = lambda do |parent_scope, *args| |