diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-05-11 08:11:17 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-05-11 08:56:01 +0100 |
commit | aa1fc1c88cb58b6387cb7a8560aac78ef56fa024 (patch) | |
tree | 61c080c9ca73b2a8d8ecf505cb8600f0b851f43b /activerecord/lib/active_record/associations/builder/singular_association.rb | |
parent | 6d51f9b98c39e13422ba321d2d5e18734895ebb2 (diff) | |
download | rails-aa1fc1c88cb58b6387cb7a8560aac78ef56fa024.tar.gz rails-aa1fc1c88cb58b6387cb7a8560aac78ef56fa024.tar.bz2 rails-aa1fc1c88cb58b6387cb7a8560aac78ef56fa024.zip |
Bring back obj.association_loaded? as a deprecated method. Fixes #472.
Diffstat (limited to 'activerecord/lib/active_record/associations/builder/singular_association.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/builder/singular_association.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/builder/singular_association.rb b/activerecord/lib/active_record/associations/builder/singular_association.rb index 06a414b874..62d48d3a2c 100644 --- a/activerecord/lib/active_record/associations/builder/singular_association.rb +++ b/activerecord/lib/active_record/associations/builder/singular_association.rb @@ -13,6 +13,19 @@ module ActiveRecord::Associations::Builder private + def define_readers + super + name = self.name + + model.redefine_method("#{name}_loaded?") do + ActiveSupport::Deprecation.warn( + "Calling obj.#{name}_loaded? is deprecated. Please use " \ + "obj.association(:#{name}).loaded? instead." + ) + association(name).loaded? + end + end + def define_constructors name = self.name |