title: Why do I get no method error when using 'grouped_collection_select'?
body: <p>When I'm loading edit page for User it shows this error. Why?  </p>
  
  <p>In my models I have models such as</p>
  
  <ul>
  <li>User (This model has one UserProfile)</li>
  <li>UserProfile (This model belongs to User, and has one Country and one Prefecture)</li>
  <li>Country (This model belongs to UserProfile, and has many Prefectures)</li>
  <li>Prefecture (This model belongs to Country and UserProfile)</li>
  </ul>
  
  <p><strong>error</strong></p>
  
  <blockquote>
    <p>undefined method `name' for #</p>
  </blockquote>
  
  <p><strong>_form.html.erb</strong></p>
  
  <pre><code>&lt;%= f.fields_for :user_profile do |profile_form| %&gt;
    &lt;%= profile_form.label :country_id %&gt;&lt;br /&gt;
    &lt;%= profile_form.collection_select :country_id, Country.order(:name_en), :id, :name_en, include_blank: true %&gt;
  
    &lt;%= profile_form.label :prefecture_id, "State or Province" %&gt;&lt;br /&gt;
    &lt;%= profile_form.grouped_collection_select :prefecture_id, Country.order(:name_en), :prefectures, :name, :id, :name, include_blank: true %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p><strong>models/country.rb</strong></p>
  
  <blockquote>
    <p>has_many :prefectures</p>
  </blockquote>
  
  <p><strong>models/prefectures.rb</strong></p>
  
  <blockquote>
    <p>belongs_to :country</p>
  </blockquote>