diff options
author | Rafael Mendonça França <rafael.franca@plataformatec.com.br> | 2014-04-22 17:20:52 -0500 |
---|---|---|
committer | Rafael Mendonça França <rafael.franca@plataformatec.com.br> | 2014-04-22 17:20:52 -0500 |
commit | c26a690b9964d90eea33f33a513ae9c349678cc0 (patch) | |
tree | 202768bd10efa7f1ad8395f324ba0e95f2b6ffc0 /activerecord/test/models | |
parent | 148d909380cf9b85a51875a6790a6d69a2d0d693 (diff) | |
parent | 47a04b8bbf35238639b00bfab500a84607d8d871 (diff) | |
download | rails-c26a690b9964d90eea33f33a513ae9c349678cc0.tar.gz rails-c26a690b9964d90eea33f33a513ae9c349678cc0.tar.bz2 rails-c26a690b9964d90eea33f33a513ae9c349678cc0.zip |
Merge pull request #14573 from habermann24/has_many_through_fix
Properly handle scoping with has_many :through. Fixes #14537.
Conflicts:
activerecord/CHANGELOG.md
activerecord/test/cases/associations/has_many_through_associations_test.rb
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/post.rb | 4 | ||||
-rw-r--r-- | activerecord/test/models/reader.rb | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb index 099e039255..629dfe4765 100644 --- a/activerecord/test/models/post.rb +++ b/activerecord/test/models/post.rb @@ -145,6 +145,10 @@ class Post < ActiveRecord::Base has_many :lazy_readers has_many :lazy_readers_skimmers_or_not, -> { where(skimmer: [ true, false ]) }, :class_name => 'LazyReader' + has_many :lazy_people, :through => :lazy_readers, :source => :person + has_many :lazy_readers_unscope_skimmers, -> { skimmers_or_not }, :class_name => 'LazyReader' + has_many :lazy_people_unscope_skimmers, :through => :lazy_readers_unscope_skimmers, :source => :person + def self.top(limit) ranked_by_comments.limit_by(limit) end diff --git a/activerecord/test/models/reader.rb b/activerecord/test/models/reader.rb index 3a6b7fad34..91afc1898c 100644 --- a/activerecord/test/models/reader.rb +++ b/activerecord/test/models/reader.rb @@ -16,6 +16,8 @@ class LazyReader < ActiveRecord::Base self.table_name = "readers" default_scope -> { where(skimmer: true) } + scope :skimmers_or_not, -> { unscope(:where => :skimmer) } + belongs_to :post belongs_to :person end |