我有以下型号:
$exam[2]
我也有这个模型,它没有被命名空间:
class Supervision::ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
def self.table_name_prefix
"supervision_"
end
end
---------------
class Supervision::Activity < Supervision::ApplicationRecord
has_one :supervision_missed_visit, class_name: Supervision::MissedVisit
(...)
end
---------------
class Supervision::MissedVisit < Supervision::ApplicationRecord
belongs_to :supervision_activity, class_name: Supervision::Activity
(...)
end
每当我尝试通过其class Activity < ApplicationRecord
(...)
end
关系尝试Supervision::MissedVisit
时,如
has_one
我收到以下错误:
@supervision_activity.supervision_missed_visit
如何让Rails明白我实际上在寻找ERROR: column supervision_missed_visits.activity_id does not exist
?
答案 0 :(得分:1)
您可以指定外键:
For i = 1 To 10
Debug.Print Me.Controls("chk" & i).Name & vbTab & Me.Controls("chk" & i).Value
Next i
另一种方法是在has_one :supervision_missed_visit, class_name: Supervision::MissedVisit, foreign_key: 'supervision_activity_id'
中创建一个实例方法:
Supervision::Activity