1
我有一個使用Active Admin的Rails應用程序。基本流程是我有一個事件模型與其他模型有關聯。連接其他模型似乎很好,但對於一個模型(涉及),特別是在創建新事件時,我得到了錯誤未初始化的常量事件:: Involf。未初始化的常量[Incident :: Involf]
事件模型看起來像這樣
class Incident < ActiveRecord::Base
# Relationships
belongs_to :admin_user
has_many :images
has_and_belongs_to_many :incident_types
has_and_belongs_to_many :involves
has_and_belongs_to_many :special_considerations
belongs_to :county
belongs_to :location
# Nested Attributes
accepts_nested_attributes_for :images
accepts_nested_attributes_for :county
accepts_nested_attributes_for :location
accepts_nested_attributes_for :incident_types
accepts_nested_attributes_for :involves
accepts_nested_attributes_for :special_considerations
end
的涉及模型看起來像這樣
class Involve < ActiveRecord::Base
# Relationships
has_and_belongs_to_many :incidents
# Aliases
alias_attribute :name, :involved
end
嵌套事件的主動管理模式是這樣的
f.inputs "Vehicles Involved" do
f.input :involves, :as => :check_boxes
end
f.inputs "Special Considerations" do
f.input :special_considerations, :as => :check_boxes
end
如有特殊事項工作如果我有f.input:涉及,:as =>:check_boxes評論out,但是如果我沒有註釋掉,我會得到這個錯誤。
看着數據庫和關聯和代碼非常相似,我不知道問題是什麼。