ユーザーの編集ページを読み込んでいると、このエラーが表示されます。なんで?
私のモデルには次のようなモデルがあります
- ユーザー(このモデルには1つのUserProfileがあります)
- UserProfile(このモデルはUserに属し、1つの国と1つの県があります)
- 国(このモデルはUserProfileに属し、多くの都道府県があります)
- 県(このモデルはCountry and UserProfileに属しています)
エラー
#の未定義のメソッド `name'
_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 %>
models / country.rb
has_many:都道府県
models / prefectures.rb
所属する:国