Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On install : the asset "active_admin.css" is not present in the asset pipeline. #6007

Closed
Andrew-Max opened this issue Jan 12, 2020 · 14 comments

Comments

@Andrew-Max
Copy link

Did you find a bug?

On a fresh install with rails 6 and rails-sass no assets get installed and going to '/admin' results in an error: The asset "active_admin.css" is not present in the asset pipeline.

Expected behavior

Should go to a login screen

Actual behavior

An error is thrown

How to reproduce

Fresh install according to the guide's 'Installation' section

@Andrew-Max
Copy link
Author

It looks like this is solved by rails generate active_admin:assets but it is worth noting that the documentation does not instruct the user to ever run this command on a fresh install.

@guilpejon
Copy link

In my case that command did not solved the error because I already had the files app/assets/javascripts/active_admin.js and app/assets/stylesheets/active_admin.scss.
Anyone else having this problem? I'm thinking it has something to do with the fact that Rails 6 uses webpack by default, but the assets are generated on app/assets.

@deivid-rodriguez
Copy link
Member

I think you're supposed to use sassc-rails instead of sass-rails, maybe that's the issue?

@deivid-rodriguez
Copy link
Member

Actually scratch that since I just realized that sass-rails is just a wrapper around sassc-rails. rails generate active_admin:install should run rails generate active_admin:assets so I don't know what's going on here. I also tried to reproduce this, but everything worked correctly.

Could you share some steps to reproduce this?

@Arugin
Copy link

Arugin commented Dec 30, 2020

Upgraded from rails 4 to rails 6, In the development envirobment everything works ok. In the production has the same error.

@deivid-rodriguez
Copy link
Member

Could you share some steps to reproduce this?

@mrtomhoward
Copy link

mrtomhoward commented Jan 15, 2021

@Arugin and others still experiencing this problem.

I had this issue today with an app that was initially built in Rails 5 and that I recently updated to Rails 6.

What fixed it for me was running rails app:update (and manually reviewing all the environment and initializer files as some are updated or overwritten by the update procedure).

I hadn't done that before now; I'd only updated the Rails Gem.

After doing that, Active Admin loads without any problems.

With my install, the newly updated config/application.rb had this line commented out:
#require "sprockets/railtie"

...which I believe is the Rails 6 way of disabling the asset pipeline (and which suits me fine as this app is API-only apart from ActiveAdmin).

But I tried loading the app wth require "sprockets/railtie uncommented, and it works fine that way too.

@oyenmwen
Copy link

oyenmwen commented Feb 1, 2021

This problem can occur with Rails 6 apps as they use Webpacker as the default asset generator. You need to explicitly configure activeadmin to use webpacker.

at active_admin installation:
run rails g active_admin:install --use_webpacker

If already installed:

add config.use_webpacker = true at config/initializers/active_admin.rb
and then run rails g active_admin:webpacker

Source: https://activeadmin.info/0-installation.html#setting-up-active-admin

@tanoargie
Copy link

This problem can occur with Rails 6 apps as they use Webpacker as the default asset generator. You need to explicitly configure activeadmin to use webpacker.

at active_admin installation:
run rails g active_admin:install --use_webpacker

If already installed:

add config.use_webpacker = true at config/initializers/active_admin.rb
and then run rails g active_admin:webpacker

Source: https://activeadmin.info/0-installation.html#setting-up-active-admin

Thanks! This fixed the issue for me!

@mmell
Copy link

mmell commented Aug 23, 2021

This happened to me on a fresh Rails 6 site. It only manifested in the production deployment.

@Zidail
Copy link

Zidail commented Aug 31, 2021

Seems like I'm having the same issue with a fresh install of Active Admin.
It works in development but doesn't in production.
Doesn't seem like webpacker picked up the scss file.

Followed the instructions in: https://activeadmin.info/0-installation.html#setting-up-active-admin

EDIT: Solved. Nothing to do with the setup. Just needed to rebuild the webpacker assets and it was good to go. Silly me. @mmell you might want to give this a try.

@mmell
Copy link

mmell commented Aug 31, 2021

Setting RAILS_SERVE_STATIC_FILES=1 in the production environment solved it for me.

@ahmadoji01
Copy link

ahmadoji01 commented Sep 24, 2021

In case someone still having the same issue after trying all the solutions above. I opened the config/webpacker.yml and change this line:

default: &default
  ...
  extract_css: true
  ...

Somehow, my app wants to have the webpacker to also emit the css for the active_admin.css to be identified. Hopefully it will help someone here

@thisismydesign
Copy link

Happens when there's no app/assets folder, e.g. for api-only apps. Fix by creating the folder or rails generate active_admin:assets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests