Skip to content

The asset 'rails_admin.css' was not found in the load path. #3731

@Cardyard

Description

@Cardyard

Describe the bug
This includes a fix, so maybe it is a documentation request.
The bug is: Cannot reach rails admin (eg http://localhost:3000/admin ) as get ..

Propshaft::MissingAssetError in RailsAdmin::Main#dashboard
Showing /home/ubuntu/.local/share/mise/installs/ruby/3.4.8/lib/ruby/gems/3.4.0/gems/rails_admin-3.3.0/app/views/layouts/rails_admin/_head.html.erb where line #23 raised:
The asset 'rails_admin.css' was not found in the load path.

Reproduction steps
Clean install of rail admin master branch (as opposed to 3.3 release in order to avoid the undefined method 'gsub!' issue) including successful rails g rails_admin:install and running bundle and yarn

Expected behavior
View the lovely rails admin screens

Additional context

  • rails version: 8.1.1
  • rails_admin version: master (3.3)
  • rails_admin npm/x package version: 10.9.4
  • Ubuntu 22.04 on WSL2

Detail
After running a successful install and bundle, its noteworthy that cssbundling-rails gem is installed, and app/assets/stylesheets/rails_admin.scss exists. Being this is the latest install of ruby and rails, assets are managed by Propshaft and the rails admin install was Importmap based.

The excellent rails admin documentation says one of the files installed is..

app/assets/stylesheets/rails_admin.scss - SCSS file to build the RailsAdmin stylesheet by using cssbundling-rails

But it doesn't say what to do with this file, but has hinted at using the cssbundling-rails gem, so this is what I did..

Fix
The fix is detailed in a different issue - 3726

Thanks ayinloya for describing the solution. I've put some explanation/context in here since I hadn't seen your contribution until I'd already written this...

We need a css preprocessor to compile scss into css, so in this case use the sass variant of cssbundling-rails.

rails css:install:sass

Among other things, this adds the following to package.json

"scripts": { "build:css":
"sass ./app/assets/stylesheets/application.sass.scss:./app/assets/builds/application.css --no-source-map --load-path=node_modules" }

Change this to...

"scripts": { "build:css":
"sass ./app/assets/stylesheets/rails_admin.scss:./app/assets/builds/rails_admin.css --no-source-map --load-path=node_modules" }

I'd hoped the compilation would happen automatically since Proc.dev is setup and foreman installed, even after saving rails_admin.scss, but it didn't happen, so I had to run the script manually...

yarn run build:css

This generated 37 deprecation warnings and reported another 356 repetitive deprecation warnings omitted. But I ignored this. The desired app/assets/stylesheets/rails_admin.scss was generated and rails_admin can be brought into view.

I must say, I totally rely on rails_admin for all my projects and it looks fab now. Thanks for a great project!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions