diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-09-02 05:12:42 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-09-02 05:12:42 +0900 |
commit | a26cff3c1235c61cd0135bed4ef63d7be452b458 (patch) | |
tree | dff1229b4d7551751f6c8f7bda266064b7be960b /activerecord/test/models | |
parent | 855e5f59f0a990bb35cacbc7e46d02206923551f (diff) | |
download | rails-a26cff3c1235c61cd0135bed4ef63d7be452b458.tar.gz rails-a26cff3c1235c61cd0135bed4ef63d7be452b458.tar.bz2 rails-a26cff3c1235c61cd0135bed4ef63d7be452b458.zip |
`values[:includes]` in `reflection_scope` is not compatible with `through_scope`
Without this fix, preloading `:comments_with_include` will cause the
following error:
```
% bundle exec ruby -w -Itest test/cases/associations/eager_test.rb -n test_eager_with_has_many_through_join_model_with_include
Using sqlite3
Run options: -n test_eager_with_has_many_through_join_model_with_include --seed 1502
E
Error:
EagerAssociationTest#test_eager_with_has_many_through_join_model_with_include:
ActiveRecord::AssociationNotFoundError: Association named 'post' was not found on Post; perhaps you misspelled it?
```
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/author.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb index 09958ca257..025d013fb4 100644 --- a/activerecord/test/models/author.rb +++ b/activerecord/test/models/author.rb @@ -21,7 +21,7 @@ class Author < ActiveRecord::Base end has_many :comments_containing_the_letter_e, through: :posts, source: :comments has_many :comments_with_order_and_conditions, -> { order("comments.body").where("comments.body like 'Thank%'") }, through: :posts, source: :comments - has_many :comments_with_include, -> { includes(:post) }, through: :posts, source: :comments + has_many :comments_with_include, -> { includes(:post).where(posts: { type: "Post" }) }, through: :posts, source: :comments has_many :first_posts has_many :comments_on_first_posts, -> { order("posts.id desc, comments.id asc") }, through: :first_posts, source: :comments |