From 9eb87fbf15b2bb68d9d16c83dfe46f88d89a915c Mon Sep 17 00:00:00 2001 From: eileencodes Date: Mon, 9 Jun 2014 13:53:41 -0400 Subject: Abstract away use of HABTM macro By having the `:has_and_belongs_to_many` macro in the `@collection` we are punishing `:has_many` associations because it has to allocate the array and check the macro. @collection is returned to `macro == :has_many` and a new reflection class `HABTMReflection` is created to handle this case instead. --- activerecord/lib/active_record/associations.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/associations.rb') diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 07dfc448e7..1d1201a838 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1577,7 +1577,7 @@ module ActiveRecord scope = nil end - habtm_reflection = ActiveRecord::Reflection::AssociationReflection.new(:has_and_belongs_to_many, name, scope, options, self) + habtm_reflection = ActiveRecord::Reflection::HABTMReflection.new(:has_and_belongs_to_many, name, scope, options, self) builder = Builder::HasAndBelongsToMany.new name, self, options -- cgit v1.2.3