我有一个使用 Active Admin 的 rails 应用程序。基本流程是我有一个事件模型与其他模型有关联。连接其他模型似乎很好,但特别是对于一个模型(涉及),我在创建新事件时收到错误未初始化常量 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
Involve 模型如下所示
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 :involves, :as => :check_boxes 注释掉,则特殊注意事项起作用,但如果我没有将它注释掉,我会收到此错误。
查看了数据库和关联,代码与其他人非常相似,我不确定问题是什么。