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 User Authentication with Rails Password Hashing and Sign In Creating the User Model: Part 1

kabir k
PLUS
kabir k
Courses Plus Student 18,036 Points

Got an error page when trying to visit http://localhost:3000/todo_lists/2/todo_items

On timeline 00:54 of the "Creating the User Model: Part 1" video, I got an error page when trying to visit

http://localhost:3000/todo_lists/2/todo_items

as Jason did

I am using a different Mac from the one I was using before when I completed the earlier part of the odot app. I am using the project files from the last part of that course. I have my server on and got the following output from the Terminal

treehouse:~/projects/odot (master) $ bin/rails server => Booting WEBrick => Rails 4.0.1 application starting in development on http://0.0.0.0:3000 => Run rails server -h for more startup options => Ctrl-C to shutdown server [2015-10-15 05:43:08] INFO WEBrick 1.3.1 [2015-10-15 05:43:08] INFO ruby 2.0.0 (2013-11-22) [i686-linux] [2015-10-15 05:43:08] INFO WEBrick::HTTPServer#start: pid=2773 port=3000

Started GET "/todo_lists/2/todo_items" for 10.0.2.2 at 2015-10-15 05:46:29 -0400

ActiveRecord::PendingMigrationError (Migrations are pending; run 'bin/rake db:migrate RAILS_ENV=development' to resolve this issue.): activerecord (4.0.1) lib/active_record/migration.rb:379:in check_pending!' activerecord (4.0.1) lib/active_record/migration.rb:366:incall' actionpack (4.0.1) lib/action_dispatch/middleware/callbacks.rb:29:in block in call' activesupport (4.0.1) lib/active_support/callbacks.rb:373:inrun338284775call_callbacks' activesupport (4.0.1) lib/active_support/callbacks.rb:80:in run_callbacks' actionpack (4.0.1) lib/action_dispatch/middleware/callbacks.rb:27:incall' actionpack (4.0.1) lib/action_dispatch/middleware/reloader.rb:64:in call' actionpack (4.0.1) lib/action_dispatch/middleware/remote_ip.rb:76:incall' actionpack (4.0.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in call' actionpack (4.0.1) lib/action_dispatch/middleware/show_exceptions.rb:30:incall' railties (4.0.1) lib/rails/rack/logger.rb:38:in call_app' railties (4.0.1) lib/rails/rack/logger.rb:20:inblock in call' activesupport (4.0.1) lib/active_support/tagged_logging.rb:67:in block in tagged' activesupport (4.0.1) lib/active_support/tagged_logging.rb:25:intagged' activesupport (4.0.1) lib/active_support/tagged_logging.rb:67:in tagged' railties (4.0.1) lib/rails/rack/logger.rb:20:incall' actionpack (4.0.1) lib/action_dispatch/middleware/request_id.rb:21:in call' rack (1.5.2) lib/rack/methodoverride.rb:21:incall' rack (1.5.2) lib/rack/runtime.rb:17:in call' activesupport (4.0.1) lib/active_support/cache/strategy/local_cache.rb:83:incall' rack (1.5.2) lib/rack/lock.rb:17:in call' actionpack (4.0.1) lib/action_dispatch/middleware/static.rb:64:incall' rack (1.5.2) lib/rack/sendfile.rb:112:in call' railties (4.0.1) lib/rails/engine.rb:511:incall' railties (4.0.1) lib/rails/application.rb:97:in call' rack (1.5.2) lib/rack/lock.rb:17:incall' rack (1.5.2) lib/rack/content_length.rb:14:in call' rack (1.5.2) lib/rack/handler/webrick.rb:60:inservice' /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/webrick/httpserver.rb:138:in service' /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/webrick/httpserver.rb:94:inrun' /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'

Rendered /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/actionpack-4.0.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.3ms) Rendered /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/actionpack-4.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.9ms) Rendered /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/actionpack-4.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.8ms) Rendered /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/actionpack-4.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (23.3ms)

Started GET "/todo_lists/2/todo_items" for 10.0.2.2 at 2015-10-15 05:54:26 -0400 ActiveRecord::SchemaMigration Load (1.3ms) SELECT "schema_migrations".* FROM "schema_migrations" Processing by TodoItemsController#index as HTML Parameters: {"todo_list_id"=>"2"} TodoList Load (2.4ms) SELECT "todo_lists".* FROM "todo_lists" WHERE "todo_lists"."id" = ? LIMIT 1 [["id", "2"]] Completed 404 Not Found in 52ms

ActiveRecord::RecordNotFound (Couldn't find TodoList with id=2): app/controllers/todo_items_controller.rb:59:in `find_todo_list'

Rendered /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/actionpack-4.0.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.6ms) Rendered /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/actionpack-4.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.1ms) Rendered /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/actionpack-4.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.9ms) Rendered /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/actionpack-4.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (19.3ms)

I also ran the ff in the Terminal, when I got the first page error

treehouse:~/projects/odot (master) $ bin/rake db:migrate RAILS_ENV=development == CreateTodoLists: migrating ================================================ -- create_table(:todo_lists) -> 0.0039s == CreateTodoLists: migrated (0.0050s) =======================================

== CreateTodoItems: migrating ================================================ -- create_table(:todo_items) -> 0.0038s == CreateTodoItems: migrated (0.0049s) =======================================

== AddCompletedAtToTodoItems: migrating ====================================== -- add_column(:todo_items, :completed_at, :datetime) -> 0.0032s == AddCompletedAtToTodoItems: migrated (0.0041s) =============================

treehouse:~/projects/odot (master) $

I got the following error page while trying to visit the localhost link in my browser.

ActiveRecord::RecordNotFound in TodoItemsController#index Couldn't find TodoList with id=2

Extracted source (around line #59): 57 58 59 60 61 62

private def find_todo_list @todo_list = TodoList.find(params[:todo_list_id]) end

def todo_item_params

Rails.root: /home/treehouse/projects/odot

Application Trace | Framework Trace | Full Trace app/controllers/todo_items_controller.rb:59:in `find_todo_list' Request

Parameters:

{"todo_list_id"=>"2"} Toggle session dump Toggle env dump Response

Headers:

None

Anyone knows how to fix this problem?

1 Answer

Seth Reece
Seth Reece
32,867 Points

Hi kabir,

Not sure if you are still stuck on this or not. You caught the first error of pending migrations. Now you are getting an error that rails can't find a TodoList with the id of 2 in the database. You can check what TodoLists you have in the rails console. Type rails console in your terminal. Then type TodoList.all.