aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorPiotr Jakubowski <piotrj@gmail.com>2016-01-20 21:53:17 +0100
committerPiotr Jakubowski <piotrj@gmail.com>2016-05-04 22:01:24 +0200
commiteebcebdeb58ff7b6c05cb1cfbbc9aa4c85c9800e (patch)
tree2b7f9fb90a4171432ddd7751fd1599eeca930d15 /activerecord/test/models
parent8352c8c6ef58eef822947faf8defc378e5de057c (diff)
downloadrails-eebcebdeb58ff7b6c05cb1cfbbc9aa4c85c9800e.tar.gz
rails-eebcebdeb58ff7b6c05cb1cfbbc9aa4c85c9800e.tar.bz2
rails-eebcebdeb58ff7b6c05cb1cfbbc9aa4c85c9800e.zip
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.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/author.rb3
1 files changed, 3 insertions, 0 deletions
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