aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-01-11 07:18:35 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-01-11 07:31:05 +0900
commitae48c65e411e01c1045056562319666384bb1b63 (patch)
tree59560db534e4ea5ec17a3a6a00c3c2c0f8b8a3aa /activerecord/test/models
parentf30f20ccec9edbffc2b80b2d7e839a4fa9ac1eac (diff)
parenteebcebdeb58ff7b6c05cb1cfbbc9aa4c85c9800e (diff)
downloadrails-ae48c65e411e01c1045056562319666384bb1b63.tar.gz
rails-ae48c65e411e01c1045056562319666384bb1b63.tar.bz2
rails-ae48c65e411e01c1045056562319666384bb1b63.zip
Merge pull request #23146 from piotrj/issue_18424
When deleting through records, take into account association conditions
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 cb8686f315..27da886e1c 100644
--- a/activerecord/test/models/author.rb
+++ b/activerecord/test/models/author.rb
@@ -88,6 +88,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