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

Deleting Todo LIsts Failure

Following along with the "Deleting Todo Lists" video, I had a code fail that passed on the video.

require 'spec_helper'

describe "Deleting todo lists" do 
    let!(:todo_list) { TodoList.create(title: "Groceries", description: "Groceries list.")
  it "is successful when clicking the destroy link" do
    visit "/todo_lists"

    within "#todo_list_#{todo_list.id}" do
        click_link "Destroy"
    expect(page).to_not have_content(todo_list.title)
    expect(TodoList.count).to eq(0)

..in Cmder..

2 deprecation warnings total

Finished in 0.01371 seconds
1 example, 1 failure

Failed examples:

rspec ./spec/features/todo_lists/destroy_spec.rb:7 # Deleting todo lists is successful when clicking the destroy link

Randomized with seed 64121

The destroy_spec.rb:7 line is the

it "is successful when clicking the destroy link" do

Any ideas at what I might be doing wrong here?

1 Answer

David Gross
David Gross
19,443 Points

I would start your rails server and see if the delete method works. If it does work it might be a problem with cabybara not being able to find the dom_id. If it doesnt work I would go through your controllers, and views and make sure you put the right code in.

   def destroy

In your todo_list.html.erb index you should have the method delete

<li><%= link_to 'Destroy', todo_list, method: :delete, data: { confirm: 'Are you sure?' } %></li>

Thanks David! Everything is working now.

I continued to the next video and after that was finished, I saw your message, went through my code and found everything was fine. Ran the test and it passed, checked the rails server and it work.

Not sure what changed!