Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ensure hm:t#find does not assign nil to :include [#1845 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information...
commit 076ca48bd649ddea4dd1a320879c03a9fe7a0a6d 1 parent 654568e
Anup Narkhede railsbob authored lifo committed
2  activerecord/lib/active_record/associations/has_many_through_association.rb
View
@@ -54,7 +54,7 @@ def construct_find_options!(options)
options[:select] = construct_select(options[:select])
options[:from] ||= construct_from
options[:joins] = construct_joins(options[:joins])
- options[:include] = @reflection.source_reflection.options[:include] if options[:include].nil?
+ options[:include] = @reflection.source_reflection.options[:include] if options[:include].nil? && @reflection.source_reflection.options[:include]
end
def insert_record(record, force = true, validate = true)
5 activerecord/test/cases/associations/has_many_through_associations_test.rb
View
@@ -299,4 +299,9 @@ def test_has_many_association_through_a_belongs_to_association
def test_has_many_association_through_a_has_many_association_with_nonstandard_primary_keys
assert_equal 1, owners(:blackbeard).toys.count
end
+
+ def test_find_on_has_many_association_collection_with_include_and_conditions
+ post_with_no_comments = people(:michael).posts_with_no_comments.first
+ assert_equal post_with_no_comments, posts(:authorless)
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.