title: Saving nested attributes for profile in user model (Rails)
body: <p>I am building small page in RoR with Devise gem and got stuck.
  When I want to save profile by nested attributes from user model there is an error and I can't get over it.</p>
  
  <p><strong>User Model</strong></p>
  
  <pre><code>has_one :profile
  accepts_nested_attributes_for :profile
  </code></pre>
  
  <p><strong>Profile Model</strong></p>
  
  <pre><code>belongs_to :user
  </code></pre>
  
  <p><strong>Edit user view (here I want to add profile information)</strong></p>
  
  <pre><code>&lt;% resource.build_profile %&gt;
  
  &lt;%= form_for(resource, :as =&gt; resource_name, 
              :url =&gt; registration_path(resource_name), 
              :html =&gt; { :method =&gt; :put, :class =&gt; "custom" }) do |f| %&gt;
  
  (some fields for user)
  
      &lt;%= f.fields_for :profile, :child_index =&gt; resource.id, 
                       :html =&gt; {:class =&gt; "custom"} do |profile| %&gt;
  
          &lt;%= profile.label :name %&gt;
          &lt;%= profile.text_field :name %&gt;
  
          &lt;%= profile.label :surname %&gt;
          &lt;%= profile.text_field :surname %&gt;
  
      &lt;% end %&gt;
      &lt;%= f.submit "Update my profile!" %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p><strong>Error in browser</strong></p>
  
  <pre><code>Internal server error
  </code></pre>
  
  <p><strong>Error in terminal</strong> </p>
  
  <pre><code>!! Unexpected error while processing request: expected Array (got Rack::Utils::KeySpaceConstrainedParams) for param `profile_attributes'
  </code></pre>
  
  <p>Thanks for help in advice :)</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>That was stupid mistake... I had this part of code in my form:</p>
  
  <pre><code>                &lt;%= profile.select :gender, %w[Male Female], {}, { :index =&gt; nil }%&gt;
  </code></pre>
  
  <p>I deleted <code>{ :index =&gt; nil }</code>, now problem is gone :)</p>