diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-09-07 07:33:38 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-09-07 07:43:44 +0900 |
commit | 3acc5d6ef7b3f000d0c541b9dc2881a8b7f40f75 (patch) | |
tree | 24d85800fdf8b5da44d07fa4fd2a55306914d4c9 /activerecord/test/models | |
parent | 0a94612a979762e1bbeb9cff13322e3f9f721ca3 (diff) | |
download | rails-3acc5d6ef7b3f000d0c541b9dc2881a8b7f40f75.tar.gz rails-3acc5d6ef7b3f000d0c541b9dc2881a8b7f40f75.tar.bz2 rails-3acc5d6ef7b3f000d0c541b9dc2881a8b7f40f75.zip |
`has_many :through` with unscope should affect to through scope
The order of scope evaluation should be from through scope to the
association's own scope. Otherwise the association's scope cannot affect
to through scope.
Fixes #13677.
Closes #28449.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/author.rb | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb index 0a52cc5390..3371fcbfcc 100644 --- a/activerecord/test/models/author.rb +++ b/activerecord/test/models/author.rb @@ -40,6 +40,7 @@ class Author < ActiveRecord::Base class_name: "Post" has_many :comments_desc, -> { order("comments.id DESC") }, through: :posts, source: :comments + has_many :unordered_comments, -> { unscope(:order).distinct }, through: :posts_sorted_by_id_limited, source: :comments has_many :funky_comments, through: :posts, source: :comments has_many :ordered_uniq_comments, -> { distinct.order("comments.id") }, through: :posts, source: :comments has_many :ordered_uniq_comments_desc, -> { distinct.order("comments.id DESC") }, through: :posts, source: :comments |