New Discussion

Notifications

You’re not receiving notifications from this thread.

JavaScript not working for Bootstrap 5 on Rails 7

5
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.

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.

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/

Try bin/importmap pin bootstrap

Hi there! It sounds like you're on an exciting journey with Ruby on Rails! Make sure to check if you're properly importing Bootstrap's JavaScript, as this can often cause issues like unresponsive dropdowns. If you're looking for a fun way to take a break, try playing Papa's Pizzeria ; it’s a great way to unwind while honing your multitasking skills! Keep up the great work!

Join the discussion
Create an account Log in

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

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

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