Steveo00
Steveo00

Reputation: 111

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

Upvotes: 10

Views: 9109

Answers (4)

Fed
Fed

Reputation: 1885

Running yarn build solved the issue for me (which in the first place was caused by running rails assets:clobber)

Upvotes: 1

Mbeche Esikanda
Mbeche Esikanda

Reputation: 1

Place this line in the application.html.erb:

<%= javascript_pack_tag 'application' %>

This worked on my end.

Upvotes: 0

Artur INTECH
Artur INTECH

Reputation: 7396

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

Rails.application.config.assets.precompile += %w(application.js)

Upvotes: 2

kyleboe
kyleboe

Reputation: 157

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.

Upvotes: 14

Related Questions