title: undefined method `prev' for
body: <h2>_form</h2>
  
  <pre><code>&lt;%= link_to 'Previous Post', blog_path(@post).previous if @post.previous %&gt;
  &lt;%= link_to 'Next Post', blog_path(@post).next if @post.next %&gt;
  </code></pre>
  
  <p>I'm so confused here, guys. <code>next</code> works, but <code>previous</code> gives me the error <code>undefined method 'previous' for "/blog/4":String</code></p>
  
  <h2>post.rb</h2>
  
  <pre><code>  def next
      Post.where("id &gt; ?", id).first
    end
  
    def previous
      Post.where("id &lt; ?", id).last
    end
  </code></pre>
  
  <p>If I switch the word <code>previous</code> to <code>last</code> then the error goes away, but instead of linking to the previous post it links to the current post.</p>