diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-09-12 23:58:37 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-09-13 00:03:09 +0100 |
commit | 1a421ceccb25b15c87e97567fff573c941aa3ab3 (patch) | |
tree | 3355394c173c476e59b1c1004d9c4cc96af89d21 /activerecord/lib | |
parent | c89e1c7bdefa2489f6ebd04862a426b7200bf494 (diff) | |
download | rails-1a421ceccb25b15c87e97567fff573c941aa3ab3.tar.gz rails-1a421ceccb25b15c87e97567fff573c941aa3ab3.tar.bz2 rails-1a421ceccb25b15c87e97567fff573c941aa3ab3.zip |
Deprecate using method_missing for attributes that are columns.
This shouldn't ever happen unless people are doing something
particularly weird, but adding a deprecation in case there are bugs not
caught by our tests.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index 8d7eb4a48d..dc6dc2e63a 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -1,4 +1,5 @@ require 'active_support/core_ext/enumerable' +require 'active_support/deprecation' module ActiveRecord # = Active Record Attribute Methods @@ -77,6 +78,20 @@ module ActiveRecord end end + def attribute_missing(match, *args, &block) + if self.class.columns_hash[match.attr_name] + ActiveSupport::Deprecation.warn( + "The method `#{match.method_name}', matching the attribute `#{match.attr_name}' has " \ + "dispatched through method_missing. This shouldn't happen, because `#{match.attr_name}' " \ + "is a column of the table. If this error has happened through normal usage of Active " \ + "Record (rather than through your own code or external libraries), please report it as " \ + "a bug." + ) + end + + super + end + def respond_to?(name, include_private = false) self.class.define_attribute_methods unless self.class.attribute_methods_generated? super |