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

Sophia Harrison
Sophia Harrison
4,534 Points

Missing rake routes...How do I create new ones?

When running "rspec spec\features\todo_items\index_spec.rb", I get the following error, which at first glance appears similar to the expected error Jason has, but is actually different. F

Failures:

1) Viewing todo items displays no items when a todo list is empty Failure/Error: visit "/todo_lists" ActionView::Template::Error: undefined method todo_list_todo_items_path' for #<#<Class:0x48da8b0>:0x488b170> # ./app/views/todo_lists/index.html.erb:20:inblock in app_views_todo_lists_index_html_erb1035370699_37907172' # C:in each' # C:ineach' # ./app/views/todo_lists/index.html.erb:15:in `_app_views_todo_lists_index_html_erb_1035370699_37907172' # ./spec/features/todo_items/index_spec.rb:6:in `block (2 levels) in <top (required)>'

Finished in 0.08 seconds 1 example, 1 failure

Failed examples:

rspec ./spec/features/todo_items/index_spec.rb:5 # Viewing todo items displays no items when a todo list is empty

Randomized with seed 27831

It seems like the error might be related to the fact that I am missing all of the "todo_list_todo_items" rake routes and only have the following:

C:\Users\Usuario\treehouse\projects\odot (master) Prefix Verb URI Pattern Controller#Action todo_items_index GET /todo_items/index(.:format) todo_items#index todo_lists GET /todo_lists(.:format) todo_lists#index POST /todo_lists(.:format) todo_lists#create new_todo_list GET /todo_lists/new(.:format) todo_lists#new edit_todo_list GET /todo_lists/:id/edit(.:format) todo_lists#edit todo_list GET /todo_lists/:id(.:format) todo_lists#show PATCH /todo_lists/:id(.:format) todo_lists#update PUT /todo_lists/:id(.:format) todo_lists#update DELETE /todo_lists/:id(.:format) todo_lists#destroy Root GET / todo_lists#index

2 Answers

Sophia Harrison
Sophia Harrison
4,534 Points

Did some research and it turns out I was missing the rake routes because the routes.rb file had not been saved.

 Odot::Application.routes.draw do
  resources :todo_lists do
    resources :todo_items
  end 
  root 'todo_lists#index' 

Well - according to the error from your rspec, it was trying to visit /todlists. According to your rake routes output (I think, it's kind of jumbled) the correct syntax is todo_lists.