Ruby Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Generate a Scaffold

Joel Buzzanco
PRO
Joel Buzzanco
Pro Student 2,738 Points

How to delete todo list (rails app)

In the video generate a scaffold, at around 4:00 he has created a todo list, is able to edit it, and finally deletes (destroys) the list. I am able to do all of this except to destroy the list. When I click destroy within my rails app, it directs me to just view the todo list that I created, instead of deleting it. I do not know why this is happening, as I coded my todo list as was shown in the videos. If someone has had this issue with rails or has any insight into this bug, I would love to hear back from you.

Jonathan Padilla
Jonathan Padilla
5,493 Points

What does your terminal show after you click delete in your browser? You can see what errors your site are throwing through there.

Some of the errors I saw before were

ActionController::RoutingError (No route matches[GET] "/javascripts/defaults.js")

or things along those lines.

Joel Buzzanco
Joel Buzzanco
Pro Student 2,738 Points

Hi Jonathan,

Sorry I didn't see your second reply.

To be honest with you, I haven't exactly pinpointed the error within the console when I click 'destroy' within the web browser.

It must just be something along the lines of, when I click destroy, the web app is not being directed to a command or file that is going to destroy the list, but rather a command to view the list. Then again, your guess is as good as mine.

There is my best guess of what may be causing it to not delete the application from error that is displayed in the console.

ActionController::RoutingError (No route matches [GET] "/stylesheets/default.css"):

Here is the full command line starting from when rails is running and I then click destroy in the web app: Thanks for your help.

C:\Users\TEST\projects\odot (master)
λ rails server
=> Booting WEBrick
=> Rails 4.2.5.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2016-04-19 14:45:24] INFO  WEBrick 1.3.1
[2016-04-19 14:45:24] INFO  ruby 2.2.3 (2015-08-18) [i386-mingw32]
[2016-04-19 14:45:24] INFO  WEBrick::HTTPServer#start: pid=8616 port=3000


Started GET "/todo_lists/1" for ::1 at 2016-04-19 14:45:24 -0400
  ActiveRecord::SchemaMigration Load (0.0ms)  SELECT "schema_migrations".* FROM "schema_migrations"
Processing by TodoListsController#show as HTML
  Parameters: {"id"=>"1"}
  TodoList Load (0.0ms)  SELECT  "todo_lists".* FROM "todo_lists" WHERE "todo_lists"."id" = ? LIMIT 1  [["id", 1]]
  Rendered todo_lists/show.html.erb within layouts/application (0.0ms)
Completed 200 OK in 438ms (Views: 365.8ms | ActiveRecord: 0.0ms)


Started GET "/javascripts/default.js" for ::1 at 2016-04-19 14:45:25 -0400

ActionController::RoutingError (No route matches [GET] "/javascripts/default.js"):
  actionpack (4.2.5.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  web-console (2.3.0) lib/web_console/middleware.rb:28:in `block in call'
  web-console (2.3.0) lib/web_console/middleware.rb:18:in `catch'
  web-console (2.3.0) lib/web_console/middleware.rb:18:in `call'
  actionpack (4.2.5.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.2.5.1) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.5.1) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.5.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.5.1) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.5.1) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.5.1) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.2.5.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
  rack (1.6.4) lib/rack/runtime.rb:18:in `call'
  activesupport (4.2.5.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  actionpack (4.2.5.1) lib/action_dispatch/middleware/static.rb:116:in `call'
  rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
  railties (4.2.5.1) lib/rails/engine.rb:518:in `call'
  railties (4.2.5.1) lib/rails/application.rb:165:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  rack (1.6.4) lib/rack/content_length.rb:15:in `call'
  rack (1.6.4) lib/rack/handler/webrick.rb:88:in `service'
  C:/Ruby22/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
  C:/Ruby22/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
  C:/Ruby22/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'


  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.5ms)
  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/templates/routes/_route.html.erb (0.0ms)
  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/templates/routes/_table.html.erb (37.8ms)
  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (0.0ms)
  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb within rescues/layout (1802.5ms)
  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/_markup.html.erb (0.0ms)
  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/_inner_console_markup.html.erb within layouts/inlined_string (0.0ms)
  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/_prompt_box_markup.html.erb within layouts/inlined_string (0.0ms)
  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/style.css.erb within layouts/inlined_string (15.6ms)
  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/console.js.erb within layouts/javascript (1239.6ms)

  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/main.js.erb within layouts/javascript (0.0ms)
  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/error_page.js.erb within layouts/javascript (0.0ms)

  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/index.html.erb (3052.6ms)


Started GET "/stylesheets/default.css" for ::1 at 2016-04-19 14:45:31 -0400

ActionController::RoutingError (No route matches [GET] "/stylesheets/default.css"):
  actionpack (4.2.5.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  web-console (2.3.0) lib/web_console/middleware.rb:28:in `block in call'
  web-console (2.3.0) lib/web_console/middleware.rb:18:in `catch'
  web-console (2.3.0) lib/web_console/middleware.rb:18:in `call'
  actionpack (4.2.5.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.2.5.1) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.5.1) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.5.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.5.1) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.5.1) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.5.1) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.2.5.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
  rack (1.6.4) lib/rack/runtime.rb:18:in `call'
  activesupport (4.2.5.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  actionpack (4.2.5.1) lib/action_dispatch/middleware/static.rb:116:in `call'
  rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
  railties (4.2.5.1) lib/rails/engine.rb:518:in `call'
  railties (4.2.5.1) lib/rails/application.rb:165:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  rack (1.6.4) lib/rack/content_length.rb:15:in `call'
  rack (1.6.4) lib/rack/handler/webrick.rb:88:in `service'
  C:/Ruby22/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
  C:/Ruby22/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
  C:/Ruby22/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'


  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (0.0ms)
  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/templates/routes/_route.html.erb (0.0ms)
  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/templates/routes/_table.html.erb (0.0ms)
  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (15.6ms)
  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/actionpack-4.2.5.1/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb within rescues/layout (1719.4ms)
  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/_markup.html.erb (0.0ms)
  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/_inner_console_markup.html.erb within layouts/inlined_string (0.0ms)
  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/_prompt_box_markup.html.erb within layouts/inlined_string (0.0ms)
  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/style.css.erb within layouts/inlined_string (0.0ms)

  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/console.js.erb within layouts/javascript (1202.4ms)

  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/main.js.erb within layouts/javascript (0.0ms)
  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/error_page.js.erb within layouts/javascript (0.0ms)

  Rendered C:/Ruby22/lib/ruby/gems/2.2.0/gems/web-console-2.3.0/lib/web_console/templates/index.html.erb (2921.7ms)

1 Answer

Jonathan Padilla
Jonathan Padilla
5,493 Points

After going through multiple stackoverflow pages all I can find are references to the gem 'coffee-script-source' and how later versions 1.8+ don't work on windows.

So within the gemfile I added the line:

gem 'coffee-script-source', '1.8.0'

then use:

bundle update

via command line to install the gem

restart your server with rails server and try again.

Hopefully that solved your issue.

Joel Buzzanco
Joel Buzzanco
Pro Student 2,738 Points

Hmm, it didn't seem to work for me.

I updated gem 'coffee-script-source', '1.8.0' in my gemfile and used bundle update in my command line. However when I run my rails server and go to the todo list I created, it still does not delete when I hit 'destroy'. In fact, I'm getting the same results as before when hitting destroy: it takes me to view my todo list. I'm not sure why. I've been trying to figure this crazy bug out for awhile now.