aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-07-15 15:17:58 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-07-15 15:17:58 -0300
commit424b379c73851ac24ab707b2743de2c9d8875e2f (patch)
tree78dd711abe9e944609b279f56473d924881dd05f /activerecord/lib/active_record
parent4f21269c0aa1ea9991cf4864b40d9918ed6e8ba9 (diff)
parent6eae366d0d2e5d5211eeaf955f56bd1dc6836758 (diff)
downloadrails-424b379c73851ac24ab707b2743de2c9d8875e2f.tar.gz
rails-424b379c73851ac24ab707b2743de2c9d8875e2f.tar.bz2
rails-424b379c73851ac24ab707b2743de2c9d8875e2f.zip
Merge pull request #20888 from sikachu/remove-support-for-force-reload
Deprecate force association reload by passing true
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/associations/collection_association.rb8
-rw-r--r--activerecord/lib/active_record/associations/singular_association.rb8
2 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb
index 6caadb4ce8..87576abd92 100644
--- a/activerecord/lib/active_record/associations/collection_association.rb
+++ b/activerecord/lib/active_record/associations/collection_association.rb
@@ -1,3 +1,5 @@
+require "active_support/deprecation"
+
module ActiveRecord
module Associations
# = Active Record Association Collection
@@ -28,6 +30,12 @@ module ActiveRecord
# Implements the reader method, e.g. foo.items for Foo.has_many :items
def reader(force_reload = false)
if force_reload
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
+ Passing an argument to force an association to reload is now
+ deprecated and will be removed in Rails 5.1. Please call `reload`
+ on the result collection proxy instead.
+ MSG
+
klass.uncached { reload }
elsif stale_target?
reload
diff --git a/activerecord/lib/active_record/associations/singular_association.rb b/activerecord/lib/active_record/associations/singular_association.rb
index bec9505bd2..30c5d72482 100644
--- a/activerecord/lib/active_record/associations/singular_association.rb
+++ b/activerecord/lib/active_record/associations/singular_association.rb
@@ -1,9 +1,17 @@
+require "active_support/deprecation"
+
module ActiveRecord
module Associations
class SingularAssociation < Association #:nodoc:
# Implements the reader method, e.g. foo.bar for Foo.has_one :bar
def reader(force_reload = false)
if force_reload && klass
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
+ Passing an argument to force an association to reload is now
+ deprecated and will be removed in Rails 5.1. Please call `reload`
+ on the parent object instead.
+ MSG
+
klass.uncached { reload }
elsif !loaded? || stale_target?
reload