Answer the question
In order to leave comments, you need to log in
Problems with routing in Rails?
I have two buttons on the page, one of them deletes Projects, the second one deletes tasks from the Current project.
and eats the routes.rb file :
delete 'todo/index' => 'todo#task_destroy', as: 'destroy_task'
delete 'todo/index' => 'projects#destroy', as: 'destroy_project'
<%= link_to image_tag("SVG/trash.svg"), destroy_project_path(project_id: project.id), method: :delete %>
<%= link_to image_tag('SVG/minus.svg'), destroy_task_path(task_id: task.id), method: :delete, remote: true %>
Answer the question
In order to leave comments, you need to log in
Routing works fine, there are problems with your code. You are giving the same path for 2 different controllers.
The solution is elementary, as you understand:
delete 'todo/index' => 'todo#task_destroy', as: 'destroy_task'
delete 'projects/index' => 'projects#destroy', as: 'destroy_project'
And if you try like this:
<%= link_to image_tag("SVG/trash.svg"), destroy_project_path(project_id: project.id), method: :delete, remote: true %>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question