fumihumiのブログ

プログラミングの備忘録

Sprockets::FileNotFound がでた

  • rails s してviewにアクセスすると Sprockets::FileNotFound になった エラー画面はこちら

gyazo.com

ActionView::Template::Error (couldn't find file 'rails-ujs' with type 'application/javascript'
Checked in these paths:
  /Users/fumihumi/project/toy_app/app/assets/config
  /Users/fumihumi/project/toy_app/app/assets/images
  /Users/fumihumi/project/toy_app/app/assets/javascripts
  /Users/fumihumi/project/toy_app/app/assets/stylesheets
  /Users/fumihumi/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/jquery-rails-4.3.1/vendor/assets/javascripts
  /Users/fumihumi/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/coffee-rails-4.2.2/lib/assets/javascripts
  /Users/fumihumi/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/actioncable-5.0.3/lib/assets/compiled
  /Users/fumihumi/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/turbolinks-source-5.0.3/lib/assets/javascripts
  /Users/fumihumi/project/toy_app/node_modules):
    4:     <title>ToyApp</title>
    5:     <%= csrf_meta_tags %>
    6:
    7:     <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
    8:     <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
    9:   </head>
   10:

app/assets/javascripts/application.js:13
app/views/layouts/application.html.erb:7:in `_app_views_layouts_application_html_erb___4143786291367192025_70271393158240'
  Rendering /Users/fumihumi/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb within rescues/layout
  Rendering /Users/fumihumi/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/middleware/templates/rescues/_source.html.erb
  Rendered /Users/fumihumi/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/middleware/templates/rescues/_source.html.erb (7.0ms)
  Rendering /Users/fumihumi/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb
  Rendered /Users/fumihumi/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.0ms)
  Rendering /Users/fumihumi/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb
  Rendered /Users/fumihumi/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (0.8ms)
  Rendered /Users/fumihumi/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/actionpack-5.0.3/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb within rescues/layout (62.9ms)
Started GET "/users" for 127.0.0.1 at 2017-09-06 16:02:18 +0900
Processing by UsersController#index as HTML
  Rendering users/index.html.erb within layouts/application
  User Load (0.2ms)  SELECT `users`.* FROM `users`
  Rendered users/index.html.erb within layouts/application (2.1ms)
Completed 200 OK in 164ms (Views: 161.4ms | ActiveRecord: 0.2ms)

該当箇所はこちらのファイル。(assets/javascripts/application.js) app/assets/javascripts/application.jsの13行目にある(はず)の

//= require rails-ujs
この記述を削除すれば治ります!