Ruby on rails rails 4分组\u集合\u选择不工作
我的应用程序有问题。我有两对模型 第一:Ruby on rails rails 4分组\u集合\u选择不工作,ruby-on-rails,attributes,models,grouped-collection-select,Ruby On Rails,Attributes,Models,Grouped Collection Select,我的应用程序有问题。我有两对模型 第一: class Nazione < ActiveRecord::Base has_many :regiones accepts_nested_attributes_for :regiones attr_accessible :nome, :regiones_attributes end 有人能帮我解决这个问题吗?R
class Nazione < ActiveRecord::Base
has_many :regiones
accepts_nested_attributes_for :regiones
attr_accessible :nome, :regiones_attributes
end
有人能帮我解决这个问题吗?Rails无法识别属于关联另一端的类,因为您的类名不是英文的。可以显式设置类名:
class Macrocategorie < ActiveRecord::Base
has_many :categories, class_name: 'Categorie'
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
class Modulo1 < ActiveRecord::Base
attr_accessible :nazione_organizzazione,:regione_organizzazione,:macrocat_sett_scient ,:cat_sett_scient
<%= 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
class Macrocategorie < ActiveRecord::Base
has_many :categories, class_name: 'Categorie'
end
ActiveSupport::Inflector.inflections do |inflect|
inflect.irregular 'categorie', 'categories'
end