I’m new to ruby on rails (and ruby) and I’m trying to get ActiveAdmin working with my model. I’ve got a lot of the simple stuff working, but ActiveAdmin (on ActiveRecord) is giving me the following error and I cannot figure out why (I’m sure I’ve misconfigured something, but I don’t know what):
Mysql2::Error: Unknown column ‘assessment_styles.assessment_definition_id’ in ‘where clause’: SELECT
assessment_styles.* FROMassessment_stylesWHEREassessment_styles.assessment_definition_id= 1 LIMIT 1
The AssessmentDefinition Model
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
The AssessmentStyle Model
class AssessmentStyle < ActiveRecord::Base
attr_accessible :name
has_many :assessment_definitions, :inverse_of => :assessmentStyle
end
What am I doing wrong?
Oops! I figured it out (with a little help from Duane’s Brain). I was misunderstanding has_one vs. belongs_to, having confused it with the plain English sense of the word and not having realised what it was doing under the hood.