Skip to content

Commit

Permalink
habtm can only ever be an association reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Jul 23, 2013
1 parent 6e24d50 commit e69d804
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions activerecord/lib/active_record/reflection.rb
Expand Up @@ -12,7 +12,9 @@ module Reflection # :nodoc:

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
Expand Down Expand Up @@ -191,7 +193,7 @@ def klass

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
Expand Down

0 comments on commit e69d804

Please sign in to comment.