title: Declare Variable from .each Iteration in Controller
body: <p>I am attempting to create a method for a self referential relationship that requires two variables to be declared in the controller method...</p>
  
  <p>1) The current record the user is viewing [record = Record.find(params[:parent_id])]</p>
  
  <p>2) The record being selected from a record.each iteration on the primary record's "Show" page as shown below...</p>
  
  <pre><code>  &lt;% Record.find_each do |record| %&gt;
      &lt;div&gt;
        &lt;%= record.name %&gt;
      &lt;/div&gt;
      &lt;%= form_for(@record.active_relationships.build) do |f| %&gt;
        &lt;div&gt;
          &lt;%= hidden_field_tag :parent_id, record.id %&gt;
        &lt;/div&gt;
        &lt;%= f.submit "Follow" %&gt;
      &lt;% end %&gt;
     &lt;% end %&gt;
  </code></pre>
  
  <p>How can this record be declared as a variable in the controller similar to that done with the primary record (1)?</p>
  
  <p>Below is the the method I have in the controller so far...</p>
  
  <pre><code>def create
          record = Record.find(params[:parent_id])
          record.follow(record)
          redirect_to record
      end
  </code></pre>
  
  <p>As you will notice there are two instances of record in the second line. the problem I am having is arising in that I am unsure as how to define the second instance of record to reflect objective 2.</p>