Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The asset “application.js” is not present in the asset pipeline in rails 7

I started new project with rails 7 and ruby 3 : rails new erdemsproject --css=bootstrap $rails g controller page index (after that in routes: root “home#index” )

$rails s

And I’m giving a basic error in localhost’s red page: The asset “application.js” is not present in the asset pipeline. on the:

<%= javascript_include_tag “application”, “data-turbo-track”: “reload”, defer: true %>

What is the mistake? I installed yarn, npm, npx and ruby again and again. But didn't solve.

like image 804
Erdem TOPAL Avatar asked Oct 13 '25 11:10

Erdem TOPAL


2 Answers

in your app/views/layouts/applications.html.erb instead of :

  <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>

do :

<%= javascript_include_tag "/assets/application.js", "data-turbo-track": "reload", defer: true %>
like image 67
Chrispaix Avatar answered Oct 15 '25 05:10

Chrispaix


For a rails 7 app initialize with css flag you need to run your project with:

./bin/dev

Because you need to build your css and js with cssbundling-rails and jsbundling-rails.

like image 25
Pedro Augusto Ramalho Duarte Avatar answered Oct 15 '25 04:10

Pedro Augusto Ramalho Duarte