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 Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Viewing Todo Items: Part 2

Couldn't find TodoList with 'id'=todo_list_id

When I click on link 'List Items', the following error is thrown:

ActiveRecord::RecordNotFound in TodoItemsController#index Couldn't find TodoList with 'id'=todo_list_id

and it complaining about this line: @todo_list = TodoList.find(params[:todo_list_id])

In the following code class TodoItemsController < ApplicationController def index @todo_list = TodoList.find(params[:todo_list_id]) end end

Thanks

1 Answer

Brandon Barrette
Brandon Barrette
20,485 Points

So I would go to that view where you are clicking the link. You have to pass the todo_list_id into the link, for example:

<%= link_to @todo_list.title, todo_list_path(@todo_list) %>

Notice I'm passing @todo_list into the todo_list_path. That adds the appropriate ID to the URL so that when the next page begins to load, it can fetch the ID and find the todo_list.

Hope that makes sense.

Brilliant, thank you very much for your help.