Hey I have seen several posts on this, but I am still having issues with calling :method => 'delete' and getting directed to the show method of my controller. The destroy method is working as expect, in that it deletes the comment, but after the request is done, it throws a 404 on GET. Here is the code:
<%= link_to 'delete', "/events/#{@event.id}/comments/#{comment.id}.js",
:confirm => 'Are you sure?',
:method => :delete,
:remote => true %>
Here is the controller method:
def destroy
@comment = @event.comments.find(params[:id])
@comment.destroy
redirect_to do |format|
format.html # redirect_to @event, :notice => "comment deleted" }
format.js { render 'destroy.js.erb' }
end
end
I've hear that this could be due to not using button_to, but I have tried using button_to as opposed to link_to but this does the same thing.
I've also heard that this could be do to some problems with the way you are using jquery in your set up, but I feel like I doubt that, but here is how I call in jquery just in case (application.html.erb):
<%= javascript_include_tag 'jquery-1.5.2.min.js', 'rails', 'application' %>
<%= javascript_include_tag 'jquery-ui-1.8.17.custom.min.js' %>
When i watch rails server output I see that it's says:
Redirected to http://0.0.0.0:3000/events/1/comments/35
Completed 302 Found in 132ms
ACTION NAME application
Started GET "/events/1/comments/35" for 127.0.0.1 at Wed Feb 08 16:31:43 -0800 2012
AbstractController::ActionNotFound (The action 'show' could not be found for CommentsController):
Thanks for the help!