Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Generate a Scaffold

Kaiyang Lin
Kaiyang Lin
5,573 Points

Can't delete the todo list entry

Hey all,

Have a problem whereby clicking on the 'destroy' button doesn't actually delete the entry! Clicking on destroy only redirects me to localhost:3000/todo_lists/1 , where the number 1 refers to the entry number. I noticed that it's an alert prompt that comes up when you click destroy, so it must be an issue with the javascript

I'm running the latest version of rails (4.2.5), on a windows 10 using the Cmder interface.

Any help is greatly appreciated! Thanks!

Francois van der Hoven
Francois van der Hoven
2,026 Points

Hi Kaiyang, it is possible that some code in your javascript intercepts the click event and does not submit the form. Your destroy method in the controller is probably not executed. I suggest you use the gem, byebug (https://github.com/deivid-rodriguez/byebug), to trace your ruby code. You should also be aware of what this javascript command does: http://www.w3schools.com/jsref/event_preventdefault.asp. I know this does not solve the problem, but these are some tools to help you.