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

Presented with a different error than Jason

I am not sure why but I am getting this error when trying to run my edit_spec. Here is the link to my github project https://github.com/hondoh/ODOT. I have been running into errors that I am not sure how to fix very frequently. If anyone is able to answer this I would appreciate any help I can get on deciphering the error messages to fix my own errors in the future. I can see where the problem comes up in my code but I am then confused on what to do to fix it especially when my code appears to be the exact same as Jason's on that specific line.

Editing todo items is successful with valid content (FAILED - 1)

Failures:

1) Editing todo items is successful with valid content Failure/Error: click_link "Edit" ActionView::MissingTemplate: Missing template todo_items/edit, application/edit with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in: * "/Library/Ruby/Gems/2.0.0/gems/web-console-2.0.0/lib/action_dispatch/templates" * "/Users/hsh2692/projects/odot/app/views" # ./spec/features/todo_items/edit_spec.rb:20:in block (3 levels) in <top (required)>' # ./spec/features/todo_items/edit_spec.rb:19:inblock (2 levels) in <top (required)>'

Finished in 0.30641 seconds 1 example, 1 failure

Failed examples:

rspec ./spec/features/todo_items/edit_spec.rb:17 # Editing todo items is successful with valid content

1 Answer

Brandon Keene
Brandon Keene
7,217 Points

Ok, I'm still working through this myself, but I pulled the code from your copy of /spec/features/todo_items/edit_spec.rb from your github and compared it against my own. For good measure (and in case I get this wrong so others can see) here is your code:

require 'spec_helper'

describe "Editing todo items" do 
    let!(:todo_list) { TodoList.create(title: "Groceries", description: "Grocery list.") }
    let!(:todo_item) { todo_list.todo_items.create(content: "Milk")}

    def visit_todo_list(list)
        visit "/todo_lists"
        within "#todo_list_#{todo_list.id}" do
            click_link "List Items"
        end
    end




    it "is successful with valid content" do
        visit_todo_list(todo_list)
        within("#todo_item_#{todo_item.id}") do
            click_link "Edit"
        end 

        fill_in "Content", with: "Lots of Milk"
        click_button "Save"
        expect(page).to have_content("Saved todo list item.")
        todo_item.reload
        expect(todo_item.content).to eq("Lots of Milk")
    end

end

The only major difference I found was on line 9. Try changing it to:

within "#todo_list_#{list.id}" do

and see if that makes a difference?

Thanks for trying to help but I actually found out that the problem was coming from my app/views/todo_items/edit.html.rb filename extension and I needed to change it from that to edit.html.erb

Brandon Keene
Brandon Keene
7,217 Points

I'm glad to hear you got it working!