title: Rails 3 how to add a custom method to controller
body: <p>I'm using the <a href="http://guides.rubyonrails.org/getting_started.html" rel="nofollow">http://guides.rubyonrails.org/getting_started.html</a> as an example to help me create my own application. I create the blog and comments modules just fine.  When I add a method to the comments or blog controllers I cannot get a link_to action to work calling the new function.  Everything points to a problem in the routes.rb but I've tried all the new syntax I've seen and nothing is working for me.  </p>
  
  <p>What I'm trying to do is create a simple execute method in the controller to run a ruby script and save the output to the database. Everything works according to the tutorial but when I try to extend the comment controller with a custom function called execute I cant get that to run. </p>
  
  <pre><code>comments_controller.rb  #Same as destroy 
  def execute
    @post = Post.find(params[:post_id])
    @comment = @post.comments.find(params[:id])
    @comment.destroy
    redirect_to post_path(@post)
   end
  
  _comment.html.erb
  &lt;%= link_to 'Execute Comment', [comment.post, comment],
      :method =&gt; :execute %&gt;
  
  routes.rb
  resources :posts do
    resources :comments do
      get :execute, :on =&gt; :member
    end
  end
  
  rake routes |grep execute
  execute_post_comment GET    /posts/:post_id/comments/:id/execute(.:format) {:action=&gt;"execute", :controller=&gt;"comments"}
  
  Error when I click Execute comment link:
  No route matches "/posts/3/comments/6"
  </code></pre>