0

アプリに問題があります。私は2組のモデルを持っています

最初:

          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

そして2番目のペア:

     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

誰でもこの問題を解決するのを手伝ってもらえますか?

4

1 に答える 1