diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-07-02 11:58:09 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-07-02 11:58:09 -0700 |
commit | a95cbabc358a6f221b288f93fd8d48d769f6d23b (patch) | |
tree | 788f7dc7b285dbddd2621184970a90b2586c32db /activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb | |
parent | f98d47b1abff6263c3bf0514c64742e15f9a02b3 (diff) | |
parent | 8ef2463807402f3e81bc5bbfe7206e2314cc79dc (diff) | |
download | rails-a95cbabc358a6f221b288f93fd8d48d769f6d23b.tar.gz rails-a95cbabc358a6f221b288f93fd8d48d769f6d23b.tar.bz2 rails-a95cbabc358a6f221b288f93fd8d48d769f6d23b.zip |
Merge pull request #11254 from neerajdotname/delete-sql-be-gone
Removed support for deprecated `delete_sql` in associations.
Diffstat (limited to 'activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb index fc0d6f7598..b2e6c708bf 100644 --- a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb +++ b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb @@ -35,22 +35,17 @@ module ActiveRecord end def delete_records(records, method) - if sql = options[:delete_sql] - records = load_target if records == :all - records.each { |record| owner.class.connection.delete(interpolate(sql, record)) } - else - relation = join_table - condition = relation[reflection.foreign_key].eq(owner.id) - - unless records == :all - condition = condition.and( - relation[reflection.association_foreign_key] - .in(records.map { |x| x.id }.compact) - ) - end - - owner.class.connection.delete(relation.where(condition).compile_delete) + relation = join_table + condition = relation[reflection.foreign_key].eq(owner.id) + + unless records == :all + condition = condition.and( + relation[reflection.association_foreign_key] + .in(records.map { |x| x.id }.compact) + ) end + + owner.class.connection.delete(relation.where(condition).compile_delete) end def invertible_for?(record) |