我有3张表/课
vectors, b_cells and transfections它们是这样关联的
class BCell
has_and_belongs_to_many :vectors ( JOIN )
class Transfection
has_and_belongs_to_many :vectors ( JOIN )如何使用关联将b_cells和转染连接起来?我试过了
class BCell
has_many :transfections, :through => :vectors
class Transfection
has_many :b_cells, :through => :vectors我使用的是rails 2.3.8
发布于 2014-04-08 00:57:30
我认为您在模型声明方面有问题。你能试试这个吗?看看能不能用?
class BCell < ActiveRecord::Base
has_many :vectors
has_many :transfections, :through => :vectors
end
class Transfection < ActiveRecord::Base
has_many :vectors
has_many :b_cells, :through => :vectors
end
class vectors < ActiveRecord::Base
belongs_to :b_cell
belongs_to :transfection
endhttps://stackoverflow.com/questions/22917715
复制相似问题