Open princetechs opened 6 months ago
look for my gem url and package.json
Ensure Proper Gem Installation:
gem 'rails_admin', '~> 3.0'
gem 'rails_admin', '~> 3.0', github: "railsadminteam/rails_admin", branch: "master"
because of a issue:-javascript_importmap_shim_nonce_configuration_tag
bundle install
to install the gem.Configure SCSS File:
app/assets/stylesheets/rails_admin.scss
file. Ensure it imports the Rails Admin base styles correctly:
$fa-font-path: ".";
@import "rails_admin/src/rails_admin/styles/base";
Modify package.json for Asset Compilation:
package.json
if using node modules to manage CSS:
{
"name": "app",
"private": "true",
"dependencies": {
"sass": "^1.77.3",
"rails_admin": "^3.1.2"
},
"scripts": {
"build:css": "sass ./app/assets/stylesheets/application.sass.scss:./app/assets/builds/application.css ./app/assets/stylesheets/rails_admin.scss:./app/assets/builds/rails_admin.css --no-source-map --load-path=node_modules"
}
}
Compile Assets:
yarn install
yarn run build:css
npm install
npm run build:css
Run Rails Asset Precompilation:
rails assets:precompile
finnally
rails s
Enjoy
This setup ensures that Rails Admin's styles are fully integrated into a Rails 7 application using Importmap, leveraging Yarn or NPM for asset management. It addresses the common pitfalls related to asset compilation in this environment and provides a clear path for developers to ensure their administrative interfaces are styled as expected.
This detailed solution aims to help anyone facing similar configuration challenges, and it's prepared to serve as a comprehensive guide for proper integration of Rails Admin in a modern Rails setup.
Isn't your issue just not following this instruction? Aside from that, the procedure almost looks same as what the install generator does: https://github.com/railsadminteam/rails_admin/issues/3648#issuecomment-1778628340
Describe the bug Integrating Rails Admin in a Rails 7 environment with Importmap and asset management via Yarn or NPM leads to an issue where the
rails_admin.scss
does not compile correctly. The styles are not applied as expected, indicating that the asset pipeline may not be properly importing styles from the specified SCSS path.Reproduction Steps
gem 'rails_admin'
to your Gemfile and runbundle install
.rails g rails_admin:install
.rails s
./admin
to observe the styling issue.Expected Behavior Navigating to the
/admin
route should display the Rails Admin interface styled correctly, showcasing a fully functional and visually appealing UI consistent with Rails Admin standards.Additional Context