title: Front-end Challenge Ruby on Rails
body: <p>In a blog app, I want the <code>Next Comment</code> button to display the next (instance) comment once the user clicks on it.</p>
  
  <p>I have the method defined and working in the <code>Comment</code> model, so my question is front-end oriented.</p>
  
  <ul>
  <li><p>How do I display the last comment dynamically? Meaning, that rails knows which comment it is and so it is able to display the next comment in line.</p></li>
  <li><p>How do I make it appear in the <code>%comment</code> html element? (AJAX?)</p></li>
  </ul>
  
  <p><code>welcome#index</code>:</p>
  
  <pre><code>- @articles.each do |article|
        .article
              %comment= article.comments.last.text
              = link_to "Next Comment", welcome_next_comment_path
  </code></pre>
  
  <p><code>welcome_controller</code>:</p>
  
  <pre><code>class WelcomeController &lt; ApplicationController
  
   def index
      ...
   end
  
   def next_comment
      find_comment
      article.comments.next(@comment)
   end
  
  private 
  
   def find_comment
      ...
   end
  end
  </code></pre>