Ask A Question

Notifications

You’re not receiving notifications from this thread.

JavaScript not working for Bootstrap 5 on Rails 7

Uday asked in Rails

Hello,
I have started learning Ruby on Rails recently. I came across your site when trying to figure out issue I am having when installing Bootstrap 5 with Rails 7.
The bootstrap framework is installed, but JavaScript is not working. (I tried with Navbar as per your video instructions, but drop-down does not work).
I did everything exactly as per instructions.

  1. Add cssbundling-rails to Gemfile with gem 'cssbundling-rails'
  2. Run $bundle install
  3. Run $rails css:install:bootstrap

Google Chrome terminal gives this error.
Uncaught TypeError: Failed to resolve module specifier "bootstrap". Relative references must start with either "/", "./", or "../".

I am just trying to learn Ruby and Rails. I do not know Javascript either, but I want to learn now. Can you please advise how to fix this?

Thanks in advance.

Reply

On Rails 7.0.1 Ruby 3.1.0, I had to run yarn to fix some issues. Also changed package.json. Note that some current Ruby and Rails versions aren't compatible. My new Rails was rails new rails71a --j esbuild --css bootstrap --database postgresql. Not sure what the tutorial used.

Reply

I have started learning Ruby on Rails recently. I came across your site when trying to figure out issue I am having when installing Bootstrap 5 with Rails 7.
The bootstrap framework is installed, but JavaScript is not working. (I tried with Navbar as per your video instructions, but drop-down does not work).
I did everything exactly as per instructions.
http://www.deanstank.net/

Reply

Try bin/importmap pin bootstrap

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,563+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.