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 Editing Todo Lists

Brian Patterson
Brian Patterson
19,588 Points

Cant get passed the initial edit spec test

I can't get past the initial edit spec test. The error message says I have a failure on line 8. This is my code.

require 'spec_helper'

describe "Editing todo lists" do 
    it "updates a todo list successfully with correct information" do
        todo_lists = TodoList.create(title: "Groceries", description: "Grocery List")

        visit "/todo_lists"
        within "#todo_list_#{todo_list.id}" do
        click_link "Edit"


        fill_in "Title", with: "New title"
        fill_in "Description", with: "New description"
        click_button "Update Todo_list"

        expect(page).to have_content("Todo list was successfully updated.")
        expect(todo_list.title).to eq("New title")
        expect(todo_list.description).to eq("New description")



Here is my error message


  1) Editing todo lists updates a todo list successfully with correct information
     Failure/Error: within "#todo_list_#{todo_list.id}" do
       undefined local variable or method `todo_list' for #<RSpec::Core::ExampleGroup::Nested_1:0xb908d2ac>
     # ./spec/features/todo_lists/edit_spec.rb:8:in `block (2 levels) in <top (required)>'

Here is the my index.html.erb

<h1>Listing todo_lists</h1>

<table> <thead> <tr> <th>Title</th> <th>Description</th> <th></th> <th></th> <th></th> </tr> </thead>

<tbody> <% @todo_lists.each do |todo_list| %> <tr id="<%= dom_id(todo_list) %>"> <td><%= todo_list.title %></td> <td><%= todo_list.description %></td> <td><%= link_to 'Show', todo_list %></td> <td><%= link_to 'Edit', edit_todo_list_path(todo_list) %></td> <td><%= link_to 'Destroy', todo_list, method: :delete, data: { confirm: 'Are you sure?' } %></td> </tr> <% end %> </tbody> </table>


<%= link_to 'New Todo list', new_todo_list_path %>

1 Answer

Hey Brian,

It should be todo_list = TodoList.create(title: "Groceries", description: "Grocery List"). You have todo_listS instead of todo_list.