aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/author.rb
diff options
context:
space:
mode:
authorAkira Matsuda <ronnie@dio.jp>2013-07-08 19:51:15 +0900
committerAkira Matsuda <ronnie@dio.jp>2013-07-10 00:40:11 +0900
commit54eee8b5f28e05376626e98650d4bde8b8451603 (patch)
tree277949c8d93173ddf04a65fefb8889ac2f0e2cd2 /activerecord/test/models/author.rb
parentc42260a3251157070a1bafadd179e4441df8933e (diff)
downloadrails-54eee8b5f28e05376626e98650d4bde8b8451603.tar.gz
rails-54eee8b5f28e05376626e98650d4bde8b8451603.tar.bz2
rails-54eee8b5f28e05376626e98650d4bde8b8451603.zip
Make sure that a joins Relation can be merged with has_many :through + association proxy
Closes #11248.
Diffstat (limited to 'activerecord/test/models/author.rb')
-rw-r--r--activerecord/test/models/author.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb
index af80b1ba42..feb828de31 100644
--- a/activerecord/test/models/author.rb
+++ b/activerecord/test/models/author.rb
@@ -13,7 +13,11 @@ class Author < ActiveRecord::Base
has_many :posts_with_extension, :class_name => "Post"
has_one :post_about_thinking, -> { where("posts.title like '%thinking%'") }, :class_name => 'Post'
has_one :post_about_thinking_with_last_comment, -> { where("posts.title like '%thinking%'").includes(:last_comment) }, :class_name => 'Post'
- has_many :comments, :through => :posts
+ has_many :comments, through: :posts do
+ def ratings
+ Rating.joins(:comment).merge(self)
+ end
+ 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