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! While you're at it, check out some resources Treehouse students have shared here.

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

Ruby

Zachary Pearson
Zachary Pearson
9,578 Points

The action 'show' could not be found for TodoItemsController

I'm working on the "Deleting Todo Items" video of the "Building a Todo List Application in Rails 4" video, and I've followed every direction in the video (and have checked several times for simple spelling errors!)

My test passes when I run it, but doesn't work correctly when I carry it out manually. When I click delete on the todo item, it doesn't ask for confirmation; it just goes straight to a page reading:

Unknown Action

The action 'show' could not be found for TodoItemsController

I'm not sure why I need a 'show' method for this, as the video didn't have one... can anyone explain?

Thanks!

3 Answers

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Here's your problem:

You commented out the whole javascript include tag in your application layout. Make sure you uncomment this line in the app/views/layouts/application.erb:

<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>

The reason: delete link like this depends on jquery-ujs, which you have in your Gemfile and assets/javascripts/application.js, but don't include in your app's header.

Also, delete the app/views/todo_items/delete.html.erb file.

Zachary Pearson
Zachary Pearson
9,578 Points

Ah, thank you - I had commented that out at the very beginning because it caused me to get an ExecJS::RuntimeUnavailable error, and I didn't know what else to do about it :)

I search that error on the forum and found another one of your posts saying to install nodejs to fix that. Works now!

Thanks!

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

You may be missing "method: :delete" in the destroy link.

Zachary Pearson
Zachary Pearson
9,578 Points

Thanks for replying, Maciej - appreciate it! I actually do have that there; here's my code:

<h1><%= @todo_list.title %></h1>

<ul class="todo_items"> <% @todo_list.todo_items.each do |todo_item| %> <li id="<%= dom_id(todo_item) %>"> <%= todo_item.content %> <%= link_to "Edit", edit_todo_list_todo_item_path(todo_item) %> <%= link_to "Delete", todo_list_todo_item_path(todo_item), method: :delete, data: { confirm: "Are you sure?" } %> </li> <% end %> </ul>

<p> <%= link_to "New Todo Item", new_todo_list_todo_item_path %> </p>

Any other ideas?

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

OK, can you publish the project on github and link it here? It will be much faster for me to run it locally and pinpoint the problem than ask you to try random snippets of code that come to my mind ;)