Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The asset "application.js" is not present in the asset pipeline in Rails 6

I am creating a RoR-6 app and I get the following error thrown from application.html.erb file from this line:

javascript_include_tag 'application', 'data-turbolinks-track': 'reload'

I get the following error:

ActionView::Template::Error: The asset "application.js" is not present in the asset pipeline.

The app was created by running rails new myapp -d postgres

I am using rails 6.0.0.rc1

like image 713
Steveo00 Avatar asked Apr 30 '19 01:04

Steveo00


2 Answers

If you do not want to use Webpack, add the following to config/initializers/assets.rb:

Rails.application.config.assets.precompile += %w(application.js)
like image 52
Artur Beljajev Avatar answered Oct 16 '22 21:10

Artur Beljajev


You'll want to use javascript_pack_tag instead of javascript_include_tag:

javascript_pack_tag 'application', 'data-turbolinks-track': 'reload'

This is required because webpacker handles javascript compilation in Rails 6.

like image 20
kyleboe Avatar answered Oct 16 '22 20:10

kyleboe