diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2011-07-06 20:13:24 -0700 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-07-06 20:13:24 -0700 |
commit | 1bad08f1168709a657110281f9a9e17c514eda92 (patch) | |
tree | e3afe448daf430c19d75e1b546a43f819d6fefa9 /activerecord | |
parent | c6578d64ca13e5089897b06a84e35a313caff84b (diff) | |
parent | 66dd2d3d10edd501c33a6aead035691a6a54f6c7 (diff) | |
download | rails-1bad08f1168709a657110281f9a9e17c514eda92.tar.gz rails-1bad08f1168709a657110281f9a9e17c514eda92.tar.bz2 rails-1bad08f1168709a657110281f9a9e17c514eda92.zip |
Merge pull request #1120 from lysenko/collection_singular_ids
collection_singular_ids ignores association :include option
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_association.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/associations/has_many_through_associations_test.rb | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index c15ee18e53..3e68f973e7 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -50,7 +50,7 @@ module ActiveRecord else column = "#{reflection.quoted_table_name}.#{reflection.association_primary_key}" - scoped.select(column).except(:includes).map! do |record| + scoped.select(column).map! do |record| record.send(reflection.association_primary_key) end end diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb index 877148bd5e..0b1ba31ac2 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -714,6 +714,11 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase assert_equal [categories(:general).id], authors(:mary).categories_like_general_ids end + def test_get_collection_singular_ids_on_has_many_through_with_conditions_and_include + person = Person.first + assert_equal person.posts_with_no_comment_ids, person.posts_with_no_comments.map(&:id) + end + def test_count_has_many_through_with_named_scope assert_equal 2, authors(:mary).categories.count assert_equal 1, authors(:mary).categories.general.count |