aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorBogdan Gusiev <agresso@gmail.com>2019-02-13 12:25:43 +0200
committerBogdan Gusiev <agresso@gmail.com>2019-02-20 13:48:51 +0200
commitbd4eff2f99ffa5868574c497bc63f320cbda3083 (patch)
treeb21d4bdea255230b35ebc142472aaf3120dfed33 /activerecord/test/models
parent4cb1438b57067d637c79d49d0662c43b5b4e64c2 (diff)
downloadrails-bd4eff2f99ffa5868574c497bc63f320cbda3083.tar.gz
rails-bd4eff2f99ffa5868574c497bc63f320cbda3083.tar.bz2
rails-bd4eff2f99ffa5868574c497bc63f320cbda3083.zip
Fix reset of the source association when through association is loaded
The special case happens when through association has a custom scope that is applied to the source association when loading. In this case, the soucre association would need to be reset after main association is loaded. See tests. The special case exists when a through association has
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/category.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/activerecord/test/models/category.rb b/activerecord/test/models/category.rb
index 2ccc00bed9..8c86879dc6 100644
--- a/activerecord/test/models/category.rb
+++ b/activerecord/test/models/category.rb
@@ -26,6 +26,7 @@ class Category < ActiveRecord::Base
has_many :categorizations
has_many :special_categorizations
has_many :post_comments, through: :posts, source: :comments
+ has_many :ordered_post_comments, -> { order(id: :desc) }, through: :posts, source: :comments
has_many :authors, through: :categorizations
has_many :authors_with_select, -> { select "authors.*, categorizations.post_id" }, through: :categorizations, source: :author