0
當我加載用戶的編輯頁面時,它顯示此錯誤。爲什麼?爲什麼使用'grouped_collection_select'時我沒有方法錯誤?
在我的模型有模型,如
- 用戶(這種模式有一個用戶配置)
- 用戶配置(此模型屬於用戶,並有一個國家和一個地區)
- 國家(這種模式屬於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 %>
型號/ country.rb
的has_many:都道府縣
型號/ prefectures.rb
belongs_to的:國家
非常感謝你 – HUSTEN