aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-07-22 22:27:25 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-07-22 22:27:25 -0700
commite69d804b5e8a5ec17368128b81e7908bb97b4fc8 (patch)
tree3ccdf87cd01f1127e410c6778db27c03932845f3 /activerecord
parent6e24d501d3a84a59feb8ed37ed71759ed8a96995 (diff)
downloadrails-e69d804b5e8a5ec17368128b81e7908bb97b4fc8.tar.gz
rails-e69d804b5e8a5ec17368128b81e7908bb97b4fc8.tar.bz2
rails-e69d804b5e8a5ec17368128b81e7908bb97b4fc8.zip
habtm can only ever be an association reflection
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/reflection.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index dac8bd7650..4bd6669f3c 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -12,7 +12,9 @@ module ActiveRecord
def self.create(macro, name, scope, options, ar)
case macro
- when :has_many, :belongs_to, :has_one, :has_and_belongs_to_many
+ when :has_and_belongs_to_many
+ klass = AssociationReflection
+ when :has_many, :belongs_to, :has_one
klass = options[:through] ? ThroughReflection : AssociationReflection
when :composed_of
klass = AggregateReflection
@@ -191,7 +193,7 @@ module ActiveRecord
attr_reader :type, :foreign_type
- def initialize(*args)
+ def initialize(macro, name, scope, options, active_record)
super
@collection = [:has_many, :has_and_belongs_to_many].include?(macro)
@automatic_inverse_of = nil