0

我是 ruby​​ on rails(和 ruby​​)的新手,我正在尝试让 ActiveAdmin 使用我的模型。我有很多简单的东西在工作,但是 ActiveAdmin(在 ActiveRecord 上)给了我以下错误,我不知道为什么(我确定我配置错误,但我不知道是什么):

Mysql2::Error:'where 子句'中的未知列'assessment_styles.assessment_definition_id':SELECT assessment_styles.* FROM assessment_styles WHERE assessment_stylesassessment_definition_id= 1 限制 1

评估定义模型

class AssessmentDefinition < ActiveRecord::Base
  attr_accessible :active, :endDOW, :endDate, :isForResearch, :name, :startDOW, :startDa>
  has_one :assessmentStyle, :inverse_of => :assessment_definitions
  has_one :consentForm

  validates :name, :endDOW, :startDOW, :endDate, :startDate, :presence => true

  has_and_belongs_to_many :courses
  has_and_belongs_to_many :groups
  has_and_belongs_to_many :behaviours

end

评估风格模型

class AssessmentStyle < ActiveRecord::Base
  attr_accessible :name
  has_many :assessment_definitions, :inverse_of => :assessmentStyle
end

我究竟做错了什么?

4

1 回答 1

0

哎呀!我想通了(在Duane's Brain的帮助下)。我误解了 has_one vs. belongs_to,将它与这个词的简单英语含义混淆了,并且没有意识到它在引擎盖下做了什么。

于 2012-08-09T02:21:40.603 回答