Artur
Artur

Reputation: 125

RoR App: "The asset 'application.css' is not present in the asset pipeline" after moving to production server

after moving my Ruby on Rails app to production server (AWS EC2 Amazon Linux 2018.03) pages don't render, because of error "The asset 'application.css' is not present in the asset pipeline" (precompiled files are presents in public/assets): production.log

However, when I refresh my application (sometimes more then once), this file is found in cache and page is rendering correctly. It seems like server doesn't wait for file precompilation or something like that. It happens not only on first page entry, but every change of view.

I followed tips from post: application.css not in asset pipeline, but it didn't help.

My stack:

I will be really grateful for any hints.

Upvotes: 7

Views: 6584

Answers (2)

stevec
stevec

Reputation: 52248

I had this problem on a GitHub Action workflow, and adding this line fixed it:

bundle exec rake assets:precompile

Example

        run: |
          bundle exec rails db:prepare
          bundle exec rake assets:precompile # <--- here

Upvotes: 1

Praveen
Praveen

Reputation: 250

You can confirm your app/assets/stylesheets folder it should have application.css file and you will have to precompile assets in production environment before go/start server in production environment. You can precompile assets using

RAILS_ENV=production rails assets:precompile

If it still does not work then you can try the config.assets.compile option to true in production.rb so it will do live compilation. Although it should be false in production environment as it impact on performance.

config.assets.compile = true

Upvotes: 6

Related Questions