aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-07-20 17:59:27 +0100
committerJon Leighton <j@jonathanleighton.com>2012-07-20 17:59:27 +0100
commita79bfa92e7bdc31b346d13ee5447d3fdac382bfb (patch)
tree248e826ef67eec232bf3f404e487d86e61d2a030 /activerecord/lib/active_record/associations
parentb16e7ed58e39328cce94b2b4d6458553fef20ed4 (diff)
downloadrails-a79bfa92e7bdc31b346d13ee5447d3fdac382bfb.tar.gz
rails-a79bfa92e7bdc31b346d13ee5447d3fdac382bfb.tar.bz2
rails-a79bfa92e7bdc31b346d13ee5447d3fdac382bfb.zip
Deprecate :finder_sql, :counter_sql, :insert_sql, :delete_sql.
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r--activerecord/lib/active_record/associations/builder/collection_association.rb11
-rw-r--r--activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb10
2 files changed, 21 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/builder/collection_association.rb b/activerecord/lib/active_record/associations/builder/collection_association.rb
index 35f9a3ae8e..f67fe17260 100644
--- a/activerecord/lib/active_record/associations/builder/collection_association.rb
+++ b/activerecord/lib/active_record/associations/builder/collection_association.rb
@@ -1,3 +1,5 @@
+require 'active_support/deprecation'
+
module ActiveRecord::Associations::Builder
class CollectionAssociation < Association #:nodoc:
CALLBACKS = [:before_add, :after_add, :before_remove, :after_remove]
@@ -19,6 +21,7 @@ module ActiveRecord::Associations::Builder
end
def build
+ show_deprecation_warnings
wrap_block_extension
reflection = super
CALLBACKS.each { |callback_name| define_callback(callback_name) }
@@ -29,6 +32,14 @@ module ActiveRecord::Associations::Builder
true
end
+ def show_deprecation_warnings
+ [:finder_sql, :counter_sql].each do |name|
+ if options.include? name
+ ActiveSupport::Deprecation.warn("The :#{name} association option is deprecated. Please find an alternative (such as using scopes).")
+ end
+ end
+ end
+
private
def wrap_block_extension
diff --git a/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb b/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb
index 0b634ab944..b997b2c3cf 100644
--- a/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb
+++ b/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb
@@ -11,6 +11,16 @@ module ActiveRecord::Associations::Builder
reflection
end
+ def show_deprecation_warnings
+ super
+
+ [:delete_sql, :insert_sql].each do |name|
+ if options.include? name
+ ActiveSupport::Deprecation.warn("The :#{name} association option is deprecated. Please find an alternative (such as using has_many :through).")
+ end
+ end
+ end
+
private
def define_destroy_hook