I am having an issue using JQuery in my RoR project in Rubymine. I am new to Ruby on Rails and want bootstrap-sass in my project. I followed the instructions from here, which is the Github bootstrap repository. I am using rails6.0.0.
And I have the following snippet in my application.html.erb:
<nav class="navbar navbar-default navbar-static-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#main-nav-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<%= link_to 'SaaS', root_path, class: 'navbar-brand' %>
</div>
<div class="collapse navbar-collapse" id="main-nav-collapse">
<ul class="nav navbar-nav navbar-right">
<li><%= link_to "Login", '#' %></li>
</ul>
</div> <!-- /.navbar-collapse-->
</div>
</nav>
A navbar-button is generated when the width drops below about 600px, however, when I click it, it does not give me the collapsed list. So I am assuming the problem is with the JQuery support.
These are the gems I imported for the JQuery support.
gem 'jquery-rails'
gem 'bootstrap-sass', '~> 3.4.1'
gem 'sassc-rails', '>= 2.1.0'
And the imports in my application.scss:
@import "bootstrap-sprockets";
@import "bootstrap";
My require statements for my application.js:
require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
//= require jquery
//= require bootstrap-sprockets
I have restarted my server several times and ran bundle install
. I, also, do not get any error when running the server or while clicking the button.
Edit: When adding the require statements to application.js, the directory stated here is different from my application.js directory.
Directory in instruction app/assets/javascripts/application.js
.
My directory app/javascript/packs/application.js
.
I created the directory asked for in the instructions and put the the require statements there.