I'm new in Ruby and in ROR framework. I try to create web app with JQuery. My steps are:
//= require jquery2
added into application.js file<%= javascript_include_tag "application" %>
into application.html.erb filewhen I try to see page in browser I see error with message:
Sprockets::Rails::Helper::AssetNotFound in LandingPage#index
The asset "application.js" is not present in the asset pipeline.
<%= javascript_include_tag "application" %>
What I doing wrong? I googled about this error, but I didn't found anything good explained.
1 What is the Asset Pipeline? The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages and pre-processors such as CoffeeScript, Sass, and ERB.
To compile your assets locally, run the assets:precompile task locally on your app. Make sure to use the production environment so that the production version of your assets are generated. A public/assets directory will be created. Inside this directory you'll find a manifest.
Webpacker is a Rails wrapper around the webpack build system that provides a standard webpack configuration and reasonable defaults.
RAILS_ENV=production tells Rails to compile the production version of the assets. assets:precompile is a Rails provided rake task that has instructions for compiling the assets.
I also ran in this error with Rails 6 (with webpack) using the syntax javascript_include_tag in the application.html.erb file.
With rails 6 and webpack use:
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With