From eebcebdeb58ff7b6c05cb1cfbbc9aa4c85c9800e Mon Sep 17 00:00:00 2001 From: Piotr Jakubowski Date: Wed, 20 Jan 2016 21:53:17 +0100 Subject: When deleting through records, take into account association conditions Fixes #18424. When deleting through records, it didn't take into account the conditions that may have been affecting join model table, but was defined in association definition. --- activerecord/test/models/author.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'activerecord/test/models') diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb index 38b983eda0..4f1cf4ef81 100644 --- a/activerecord/test/models/author.rb +++ b/activerecord/test/models/author.rb @@ -85,6 +85,9 @@ class Author < ActiveRecord::Base has_many :special_categories, :through => :special_categorizations, :source => :category has_one :special_category, :through => :special_categorizations, :source => :category + has_many :special_categories_with_conditions, -> { where(categorizations: {special: true}) }, :through => :categorizations, :source => :category + has_many :nonspecial_categories_with_conditions, -> { where(categorizations: {special: false}) }, :through => :categorizations, :source => :category + has_many :categories_like_general, -> { where(:name => 'General') }, :through => :categorizations, :source => :category, :class_name => 'Category' has_many :categorized_posts, :through => :categorizations, :source => :post -- cgit v1.2.3