Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Pol Guixe Jove
Courses Plus Student 5,948 PointsHow does Ruby on Rails know that when calling method: :delete it needs to use the method destroy in the controller?
In the ODOT app, when implementing the delete function for the todo list items we need to add a Delete link:
<%= link_to "Delete", todo_list_todo_item_path(item), method: :delete, data: {confirm: "Are you sure?"} %>
the specified method: is :delete, but when running the test the failure appears because it couldn't find method destroy
Failures:
1) Deleting todo items is succesfull
Failure/Error: click_link "Delete"
AbstractController::ActionNotFound:
The action 'destroy' could not be found for TodoItemsController
# ./spec/features/todo_items/delete_spec.rb:18:in `block (3 levels) in <top (required)>'
# ./spec/features/todo_items/delete_spec.rb:17:in `block (2 levels) in <top (required)>'
How does Ruby on Rails know that when calling method: :delete needs to execute method destroy in the todo_items_controller?
1 Answer

Maciej Czuchnowski
36,441 PointsHow does it know that index uses GET? Why does create use POST? It's just designed this way I suppose.
http://stackoverflow.com/questions/778385/rails-post-put-get
Pol Guixe Jove
Courses Plus Student 5,948 PointsPol Guixe Jove
Courses Plus Student 5,948 PointsOk. :)