Adding Bootstrap to Rails 7 Link to heading

Reference: How to Install Bootstrap in Rails 7 using importmaps without node.js

Instructions Link to heading

  1. Add the following to Gemfile:

    gem "bootstrap"
    gem "sassc-rails"
    

    Then bundle install

  2. Rename application.css to application.scss

  3. Import Bootstrap styles in app/assets/stylesheets/application.scss:

    @import "bootstrap";
    
  4. Include bootstrap in your app/javascript/application.js:

    import "popper"
    import "bootstrap"
    
  5. Go to config/importmap.rb and add the following:

    pin "popper", to: 'popper.js', preload: true
    pin "bootstrap", to: 'bootstrap.min.js', preload: true
    
  6. Add the following to config/initializers/assets.rb:

    Rails.application.config.assets.precompile += %w( bootstrap.min.js popper.js)