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 Cleaning Up Our Code

THOMAS THOMPSON
THOMAS THOMPSON
4,275 Points

Rake errors

Randomized with seed 49947

/usr/local/Cellar/ruby/2.2.1/bin/ruby -S rspec ./spec/controllers/todo_items_controller_spec.rb ./spec/features/todo_items/create_spec.rb ./spec/features/todo_items/edit_spec.rb ./spec/features/todo_items/index_spec.rb ./spec/features/todo_lists/create_spec.rb ./spec/features/todo_lists/delete_spec.rb ./spec/features/todo_lists/edit_spec.rb ./spec/helpers/todo_items_helper_spec.rb ./spec/models/todo_item_spec.rb ./spec/models/todo_list_spec.rb ./spec/views/todo_items/index.html.erb_spec.rb failed TDMT-Mac-Pro:testapp Admin$ rake /usr/local/Cellar/ruby/2.2.1/bin/ruby -S rspec ./spec/controllers/todo_items_controller_spec.rb ./spec/features/todo_items/create_spec.rb ./spec/features/todo_items/edit_spec.rb ./spec/features/todo_items/index_spec.rb ./spec/features/todo_lists/create_spec.rb ./spec/features/todo_lists/delete_spec.rb ./spec/features/todo_lists/edit_spec.rb ./spec/helpers/todo_items_helper_spec.rb ./spec/models/todo_item_spec.rb ./spec/models/todo_list_spec.rb ./spec/views/todo_items/index.html.erb_spec.rb .......F..............

Pending: todo_items/index.html.erb add some examples to (or delete) /Users/Admin 1/Documents/Test App/testapp/spec/views/todo_items/index.html.erb_spec.rb # No reason given # ./spec/views/todo_items/index.html.erb_spec.rb:4 TodoItemsHelper add some examples to (or delete) /Users/Admin 1/Documents/Test App/testapp/spec/helpers/todo_items_helper_spec.rb # No reason given # ./spec/helpers/todo_items_helper_spec.rb:14

Failures:

1) TodoItemsController GET 'index' returns http success Failure/Error: get 'index' ActionController::UrlGenerationError: No route matches {:action=>"index", :controller=>"todo_items"} # ./spec/controllers/todo_items_controller_spec.rb:7:in `block (3 levels) in <top (required)>'

I get the following error from rake.

THOMAS THOMPSON
THOMAS THOMPSON
4,275 Points

Also have the error : 2) Viewing todo items displays item content when todo list has items Failure/Error: expect(page.all("ul.todo_items li").size).to eq(2)

   expected: 2
        got: 4

   (compared using ==)
 # ./spec/features/todo_items/index_spec.rb:28:in `block (2 levels) in <top (required)>'

2 Answers

Dylan Shine
Dylan Shine
17,565 Points

1) TodoItemsController GET 'index' returns http success Failure/Error: get 'index' ActionController::UrlGenerationError: No route matches {:action=>"index", :controller=>"todo_items"} # ./spec/controllers/todo_items_controller_spec.rb:7:in `block (3 levels) in '

I haven't touched Rails in a minute, but it looks to me that you don't have an index route for your todo_items.

First go to your routes.rb file in your config folder and add the index GET request route or just add "resources:" for your todo_items.

http://guides.rubyonrails.org/routing.html Section 2.1

Then head over to your todo_items controller and create a method definition for that route, it might look like

class TodoItemController < ApplicationController
  def index
  end
end

Don't worry about putting anything in, Rails assumes by default you're going to return it's corresponding template...convention over configuration.

Then head over to your views folder for the todo_items and create the index.html.erb file and add w/e the course is asking you to add.

Your test should pass now, to make a long story short you don't have the route for the index controller action and that's why rspec is yelling at you.

Best, Dylan

THOMAS THOMPSON
THOMAS THOMPSON
4,275 Points

Thank you for the explanation Dylan, I deleted the controller entirely that was causing the index issue. The listing was a markup mistake where I was listing the item twice in the list. One was just the title the other contained the title and the edit button.