title: Ruby on Rails: link_to action, no route matches
body: <p>I'm getting into Rails and trying to add a "vote" feature on a blog setup from here: <a href="http://guides.rubyonrails.org/getting_started.html" rel="nofollow">http://guides.rubyonrails.org/getting_started.html</a></p>
  
  <p>In app/controllers/posts_controller.rb I created this:</p>
  
  <pre><code>  def incvotes
      @post = Post.find(params[:id])
      post.update_attributes(:upvotes =&gt; 1 )
      format.html { redirect_to(@post, :notice =&gt; 'Vote counted.') }
      format.xml  { head :ok }
    end
  </code></pre>
  
  <p>In app/views/posts/index.html.erb I created this:</p>
  
  <pre><code>&lt;%= link_to 'Vote', :controller =&gt; "posts", :action =&gt; "incvotes", :id =&gt; post.id %&gt;
  </code></pre>
  
  <p>But the link is giving the error</p>
  
  <blockquote>
    <p>No route matches {:controller=>"posts", :action=>"incvotes", :id=>1}</p>
  </blockquote>
  
  <p>I'm missing something here, but not sure what.</p>
  
  <p>rake routes:</p>
  
  <pre><code>incvotes_post POST   /posts/:id/incvotes(.:format) {:action=&gt;"incvotes", :controller=&gt;"posts"}
          posts GET    /posts(.:format)              {:action=&gt;"index", :controller=&gt;"posts"}
                POST   /posts(.:format)              {:action=&gt;"create", :controller=&gt;"posts"}
       new_post GET    /posts/new(.:format)          {:action=&gt;"new", :controller=&gt;"posts"}
      edit_post GET    /posts/:id/edit(.:format)     {:action=&gt;"edit", :controller=&gt;"posts"}
           post GET    /posts/:id(.:format)          {:action=&gt;"show", :controller=&gt;"posts"}
                PUT    /posts/:id(.:format)          {:action=&gt;"update", :controller=&gt;"posts"}
                DELETE /posts/:id(.:format)          {:action=&gt;"destroy", :controller=&gt;"posts"}
     home_index GET    /home/index(.:format)         {:action=&gt;"index", :controller=&gt;"home"}
           root        /(.:format)                   {:action=&gt;"index", :controller=&gt;"home"}
  </code></pre>