3

Getting Following Error ActiveRecord::HasManyThroughCantAssociateThroughHasOneOrManyReflection in ProjectController#create

Cannot modify association 'ProjectMaster#tag_masters' because the source reflection class 'TagMaster' is associated to 'ProjectTag' via :has_many.

Following are my models.

class ProjectTag < ActiveRecord::Base
  has_many :tag_masters
  has_many :project_masters
end

class TagMaster < ActiveRecord::Base
  has_many :project_tags
  has_many :project_masters, :through => :project_tags  
end

class ProjectMaster < ActiveRecord::Base
  has_many :project_tags
  has_many :tag_masters, :through => :project_tags
  # Some more code and associations here..
end

I am new to rails and tried to solve it but I don't think i can change my associations.

I am using rails 3.0.10

Please help me out here.

  • Thanks
Hector Villarreal
  • 822
  • 10
  • 20
Kashyap
  • 479
  • 5
  • 17
  • I think my associations were wrong. class ProjectTag < ActiveRecord::Base
    has_many :tag_masters
    has_many :project_masters
    end instead of has_many; I had to use belongs_to.
    – Kashyap Dec 13 '11 at 12:44

1 Answers1

0

I think my associations were wrong.

class ProjectTag < ActiveRecord::Base
  has_many :tag_masters 
  has_many :project_masters 
end

instead of has_many; I had to use belongs_to.

animuson
  • 53,861
  • 28
  • 137
  • 147
Kashyap
  • 479
  • 5
  • 17