我的应用程序有问题。我有两对模型
首先:
class Nazione < ActiveRecord::Base
has_many :regiones
accepts_nested_attributes_for :regiones
attr_accessible :nome, :regiones_attributes
end
和
class Regione < ActiveRecord::Base
belongs_to :nazione
attr_accessible :nome, :nazione_id
end
第二对:
class Macrocategorie < ActiveRecord::Base
has_many :categories
accepts_nested_attributes_for :categories
attr_accessible :nome, :categories_attributes
end
和
class Categorie < ActiveRecord::Base
belongs_to :macrocategorie
attr_accessible :nome, :macrocategorie_id
end
它们用于另一个名为 Modulo1 的模型中的表单:
class Modulo1 < ActiveRecord::Base
attr_accessible :nazione_organizzazione,:regione_organizzazione,:macrocat_sett_scient ,:cat_sett_scient
当我使用时,以 Modulo1 的形式:
<%= f.label :Nazione%><br />
<%= f.collection_select :nazione_organizzazione, Nazione.order(:nome), :nome,
:nome,{:prompt => "Seleziona una Nazione"} %>
<%= f.label :Regione %><br>
<%= f.grouped_collection_select :regione_organizzazione, Nazione.order(:nome),
:regiones, :nome, :nome, :nome, {:prompt => "Seleziona una Regione"} %>
有用!但如果我使用
<%= f.label :Settore_Scientifico %><br>
<%= f.collection_select :macrocat_sett_scient, Macrocategorie.order(:nome), :nome,
:nome, {:prompt => "Seleziona una Macrocategoria"} %>
<%= f.grouped_collection_select :cat_sett_scient,
Macrocategorie.order(:nome),:categories,:nome, :nome,:nome,
{:prompt => "Seleziona una Categoria"} %>
它不工作!错误是这样的:
uninitialized constant Macrocategorie::Category
谁能帮我解决这个问题?