title: Rails - nested loops inside view
body: <p>I'm taking up rails as a hobby but I'm still fairly new so apologies if this sounds ridiculous. I'm creating a board that can have many statuses. And each status can have many notes. However, this error comes up once I added the notes loop into the status loop on the view:</p>
  
  <pre><code>undefined method `notes' for nil:NilClass
  </code></pre>
  
  <p>Snippet of the boards/show.html.erb file:</p>
  
  <pre><code>&lt;% @board.statuses.each do |status| %&gt;
      &lt;div&gt;
          &lt;h2&gt;&lt;%= link_to status.name, status_url(status)%&gt;&lt;/h2&gt;
          &lt;% @status.notes.each do |note| %&gt;
              &lt;h2&gt;&lt;%= link_to notes.content, note_url(note)%&gt;&lt;/h2&gt;
          &lt;% end %&gt;
          &lt;%= link_to 'New notes', new_note_path(@note)  %&gt;
      &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>I'm not sure if I'm doing something wrong within the controllers or the view though. I've been having a hard time figuring it out. I appreciate any help though!</p>
  
  <p><strong>notes_controller</strong>:</p>
  
  <pre><code>class NotesController &lt; ApplicationController
    def new
      @note = Note.new
    end
    def create
      Note.create(note_params.merge(status_id: current_user.id))
      redirect_to boards_url
    end
    def delete
      Note.find(params[:id]).destroy(note_params)
    end
    def update
      Note.find(params[:id]).update(note_params)
    end
    def note_params
      params.require(:note).permit(:status_id, :content)
    end
  end
  </code></pre>
  
  <p><strong>statuses_controller</strong>:</p>
  
  <pre><code>class StatusesController &lt; ApplicationController
    def new
      @status = Status.new
    end
    def create
      Status.create(status_params.merge(board_id: current_user.id))
      redirect_to :root
    end
    def delete
      Status.find(params[:id]).destroy(status_params)
    end
    def update
      Status.find(params[:id]).update(status_params)
    end
    def show
      @status = Status.find(params[:id])
    end
    def status_params
      params.require(:status).permit(:board_id, :name)
    end
  end
  </code></pre>
  
  <p>Any more information required then let me know. Thank you. :)</p>