通过麻烦积极记录

时间:2013-09-21 10:50:00

标签: ruby-on-rails ruby activerecord

我有三种型号。

class Location < ActiveRecord::Base
  attr_accessible :description
  belongs_to :user
  has_many :zones
  has_many :iteractions, :through => :zones
end

class Zone < ActiveRecord::Base
  attr_accessible :description
  belongs_to :location
  has_many :iteractions
end

class Iteraction < ActiveRecord::Base
  attr_accessible :count, :itime
  belongs_to :zone
  belongs_to :location, :through => :zone
end

所以我尝试安装rails_admin 对我说“未知密钥:通过(参数错误)”

错误在哪里?

1 个答案:

答案 0 :(得分:3)

belongs_to关联不能有:through选项。相反,您可以使用has_one :location, :through => :zone