0

我需要一些帮助。我有 2 节课:

共享信息

class SharedInfo < ActiveRecord::Base
  attr_accessible :shared_info_type_id, :severity_id, :source_info_id, :created_date
  belongs_to :Severity, :foreign_key => :severity_id
  belongs_to :SharedInfoType, :foreign_key => :shared_info_type_id
  belongs_to :SourceInfo, :foreign_key => :source_info_id
end

严重性

class Severity < ActiveRecord::Base  
  has_many :SharedInfo, :foreign_key => :severity_id  
end

问题是:
我有一个 class@sharedinfo实例SharedInfo。当我调用以下语句时:

@sharedinfo.Severity

它返回一个错误:“未定义”。我究竟做错了什么?

4

1 回答 1

1

你已经使用了camelized类。您需要将它们替换为underscore.

belongs_to :severity, :foreign_key => :severity_id
belongs_to :shared_info_type, :foreign_key => :shared_info_type_id
belongs_to :source_info, :foreign_key => :source_info_id

高温高压

于 2013-04-22T05:00:15.203 回答