title: How do I load fields using fields_for :symbol - but only render the form field for the final object that the symbol references?
body: <p>I have a <code>Category</code> model that <code>has_many</code> <code>Skills</code>.</p>
  
  <p>I have a page where I want a user to be able to add a single new <code>skill</code> to a selected <code>category</code> via a textbox (just the name of the <code>skill</code>), while listing all existing on a page <code>categories</code> and the <code>skills</code> within those <code>categories</code>.</p>
  
  <p>I can currently display all the <code>categories</code> with their contained <code>skills</code>, but <strong>I'm not sure how to make it so a user can only create a new <code>skill</code> without being able to edit all the other <code>skills</code></strong> that <code>belongs_to</code> a <code>category</code>.</p>
  
  <p>Here is the code that I have currently:</p>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>def show
    . . .
    #needed for showing all categories
    @categories = current_user.categories
    #needed to show a blank skill when editing a category
    @skills = []
    @categories.each do |cat|
      @skills &lt;&lt; cat.skills.build
    end
    . . .
  end
  </code></pre>
  
  <p><strong>View:</strong></p>
  
  <pre><code>&lt;% @categories.each do |category| %&gt; # I skip most of the code related to formatting
      &lt;%= simple_form_for(category) do |f| %&gt;
        &lt;%= f.fields_for :skills do |s| %&gt;
          &lt;div class="inputs"&gt;
            &lt;%= s.input :name %&gt; 
            &lt;%= s.hidden_field :category_id %&gt;
            &lt;%= s.hidden_field :id %&gt;
          &lt;/div&gt;
        &lt;% end %&gt;
            &lt;%= f.button :submit %&gt;
      &lt;% end %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>And it ultimately results in a form that looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/BgfgC.png" alt="able to edit every skill"></p>
  
  <p>I have tried to change <code>f.fields_for :skills</code> to <code>f.fields_for category.skills.last</code>(because the last object in <code>category.skills</code> is a new skill that was created in the controller) and this results in a blank text box that looks like what I need:</p>
  
  <p><img src="https://i.stack.imgur.com/xudNc.png" alt="Only renders the blank skill field, but cannot submit it"></p>
  
  <p>But when I submit the form, I get a "<em>param not found: category</em>" error (that points to my params.require(:category). . . line in my Category controller.  </p>
  
  <p>I'm not sure why the form works if I use the symbol for <code>:skills</code> but doesn't work when I use <code>category.skills.last</code> (or even <code>category.skills.each</code> - I get a different error when I do that: <em>undefined method `model_name' for Enumerator:Class</em>).</p>
  
  <p>What am I doing wrong?</p>