当我为用户加载编辑页面时,它会显示此错误。为什么?
在我的模型中,我有诸如
- 用户(此模型有一个 UserProfile)
- UserProfile(此模型属于用户,有一个国家和一个地区)
- 国家(这个模型属于UserProfile,有很多州)
- 县(该模型属于 Country 和 UserProfile)
错误
# 未定义的方法“名称”
_form.html.erb
<%= f.fields_for :user_profile do |profile_form| %>
<%= profile_form.label :country_id %><br />
<%= profile_form.collection_select :country_id, Country.order(:name_en), :id, :name_en, include_blank: true %>
<%= profile_form.label :prefecture_id, "State or Province" %><br />
<%= profile_form.grouped_collection_select :prefecture_id, Country.order(:name_en), :prefectures, :name, :id, :name, include_blank: true %>
<% end %>
模型/国家.rb
has_many :都道府县
模型/地区.rb
归属地:国家