1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails チュートリアルで生じたRails Asset Pipeline周りのエラー

Posted at

#Rails チュートリアルでのエラー

5章に入り、久しぶりにサーバーを走らせると次のようなエラーが生じた。
対策にだいぶ困ったので、解決策だけ備忘録として書いておく。
なお、当方初学者につき、どうしてこれで解決したのかは全く分かりません。

##エラー内容

ActionView::Template::Error (The asset "application.js" is not present in the asset pipeline.):
     5:     <%= csrf_meta_tags %>
     6:     <%= stylesheet_link_tag    'application', media: 'all',
     7:                                'data-turbolinks-track': 'reload' %>
     8:     <%= javascript_include_tag 'application',
     9:                                'data-turbolinks-track': 'reload' %>
    10:     <!--[if lt IE 9]>
    11:       <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/r29/html5.min.js">'

##解決策
なぜか、ファイルが自動作成されていなかった
app/assets/javascripts/application.js
を作成し、
この記事を参考に(https://blog.kasei-san.com/entry/2015/09/13/185400)
以下のように記述。

app/assets/javascripts/application.js
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?