I need some help on the following model design :
User model (user.rb)
class User < ActiveRecord::Base
has_many :analyses, :dependent => :destroy
Analysis model (analysis.rb)
class Analysis < ActiveRecord::Base
belongs_to :instructor, :class_name => “User”, :foreign_key
=> :instructor_id
belongs_to :member, :class_name => “User”, :foreign_key
=> :member_id
creating an analysis works
Analysis.create(:instructor_id => 1, :member_id => 2, :status =>
“pending”)
I can get :
Analysis.first.instructor
Analysis.first.member
BUT
User.find(1).analyses raise an error :
ActiveRecord::StatementInvalid: Mysql::Error: Unknown column
‘analyses.user_id’
is there any way to handle this design ?
thanks a lot for your help
(btw I use the inflection plural analysis -> analyses)