Skip to content
Browse files

Merge pull request #10094 from neerajdotname/fix2

Collection of small fixes. Check individual commits for background.
  • Loading branch information...
2 parents f283458 + 261520d commit 507812fdf32586a59071efabdfc471402bd589f3 @carlosantoniodasilva carlosantoniodasilva committed Apr 4, 2013
View
2 activerecord/lib/active_record/associations/association_scope.rb
@@ -101,7 +101,7 @@ def add_constraints(scope)
scope.includes! item.includes_values
scope.where_values += item.where_values
- scope.order_values += (item.order_values - scope.order_values)
+ scope.order_values |= item.order_values
end
end
View
22 activerecord/lib/active_record/reflection.rb
@@ -436,6 +436,17 @@ def through_reflection
# The chain is built by recursively calling #chain on the source reflection and the through
# reflection. The base case for the recursion is a normal association, which just returns
# [self] as its #chain.
+ #
+ # class Post < ActiveRecord::Base
+ # has_many :taggings
+ # has_many :tags, through: :taggings
+ # end
+ #
+ # tags_reflection = Post.reflect_on_association(:tags)
+ # tags_reflection.chain
+ # #=> [<ActiveRecord::Reflection::ThroughReflection: @macro=:has_many, @name=:tags, @options={:through=>:taggings}, @active_record=Post>,
+ # <ActiveRecord::Reflection::AssociationReflection: @macro=:has_many, @name=:taggings, @options={}, @active_record=Post>]
+ #
def chain
@chain ||= begin
chain = source_reflection.chain + through_reflection.chain
@@ -506,9 +517,16 @@ def association_primary_key(klass = nil)
source_reflection.options[:primary_key] || primary_key(klass || self.klass)
end
- # Gets an array of possible <tt>:through</tt> source reflection names:
+ # Gets an array of possible <tt>:through</tt> source reflection names in both singular and plural form.
#
- # [:singularized, :pluralized]
+ # class Post < ActiveRecord::Base
+ # has_many :taggings
+ # has_many :tags, through: :taggings
+ # end
+ #
+ # tags_reflection = Post.reflect_on_association(:tags)
+ # tags_reflection.source_reflection_names
+ # #=> [:tag, :tags]
#
def source_reflection_names
@source_reflection_names ||= (options[:source] ? [options[:source]] : [name.to_s.singularize, name]).collect { |n| n.to_sym }
View
2 guides/bug_report_templates/active_record_gem.rb
@@ -25,7 +25,7 @@ class Comment < ActiveRecord::Base
belongs_to :post
end
-class HasManyBugTest < MiniTest::Unit::TestCase
+class BugTest < MiniTest::Unit::TestCase
def test_association_stuff
post = Post.create!
post.comments << Comment.create!
View
2 guides/bug_report_templates/active_record_master.rb
@@ -36,7 +36,7 @@ class Comment < ActiveRecord::Base
belongs_to :post
end
-class HasManyBugTest < MiniTest::Unit::TestCase
+class BugTest < MiniTest::Unit::TestCase
def test_association_stuff
post = Post.create!
post.comments << Comment.create!

0 comments on commit 507812f

Please sign in to comment.
Something went wrong with that request. Please try again.