diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2017-01-09 19:58:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-09 19:58:22 +0100 |
commit | 3bc747bd8676dc940b531067e2861dcd4ac28efc (patch) | |
tree | 6f38def712f41f26a4e6d1a40afa65a52000560f /activerecord/lib/active_record | |
parent | 2b555ee9d7b3b246cc1660de799e3fb83b8fb84f (diff) | |
parent | 8312a0d22212798864f142b5a94805e0baa6c562 (diff) | |
download | rails-3bc747bd8676dc940b531067e2861dcd4ac28efc.tar.gz rails-3bc747bd8676dc940b531067e2861dcd4ac28efc.tar.bz2 rails-3bc747bd8676dc940b531067e2861dcd4ac28efc.zip |
Merge pull request #27551 from kirs/deprecate-class-name-as-class
Deprecate reflection class name to accept a class
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/reflection.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 72f1ac4896..2da85df9e9 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -364,6 +364,17 @@ module ActiveRecord @constructable = calculate_constructable(macro, options) @association_scope_cache = {} @scope_lock = Mutex.new + + if options[:class_name] && options[:class_name].class == Class + ActiveSupport::Deprecation.warn(<<-MSG.squish) + Passing a class to the `class_name` is deprecated and will raise + an ArgumentError in Rails 5.2. It eagerloads more classes than + necessary and potentially creates circular dependencies. + + Please pass the class name as a string: + `belongs_to :client, class_name: 'Company'` + MSG + end end def association_scope_cache(conn, owner) |