4

I am using webpacker for my asset pipeline in my rails app. I installed active admin as per the documentation. I moved the styleheet file and javascript file active_admin.js.coffee and active_admin.css from app/assets/stylesheets and app/assets/javascripts to vendor directory. To load these files from vendor directory I added following lines in my config/initializers/assets.rb

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

But still rails is not able to find the file in my assets pipeline. It throws me error whenever I visit /admin path.

    Sprockets::Rails::Helper::AssetNotFound in ActiveAdmin::Devise::Sessions#new
Showing /home/rabin/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activeadmin-1.3.0/app/views/layouts/active_admin_logged_out.html.erb where line #9 raised:

The asset "active_admin.css" is not present in the asset pipeline.

I searched for entire stackoverflow but still can't figure out the problem.

Rabin Poudyal
  • 717
  • 6
  • 20

2 Answers2

2

ActiveAdmin on version 2.7.0 added Webpacker support, so after updating to this version (or above) according to docs ActiveAdmin will generate the needed files for you. Write:

rails g active_admin:install --use_webpacker

If you are not using Device add --skip-users after --use_webpacker

Unlike the usual generation ActiveAdmin will generate:

app/javascript/stylesheets/active_Admin.scss
app/javascript/packs/active_admin.js

This will download the needed js and CSS file with yarn, and update the Webpack to use jquery on all the pages (if you already set jquery, it will be worth removing the duplicate code) If you updating from Sprockets don't forget to remove the previous js and CSS from assets or vendor folder.

GEkk
  • 1,336
  • 11
  • 20
-2

It should have been inside vendor/assets directory.

Rabin Poudyal
  • 717
  • 6
  • 20
  • Could you please explain it wider? I have the same issue and cannot resolve it. How you supposed to move them to `vendor/assets`? Is there a changes in capistrano deploy config? I mean another linked directory? – Gtx Jul 24 '18 at 12:38
  • There are no details in this answer. – baash05 Mar 04 '19 at 21:52