*問題
Bootstrapのnavでheaderにドロップダウンメニューを導入しているのですが、ドロップダウンが開く場合と開かない場合があり困っています。

navbarには現在ビューのあるリンクとしてHome画面とEdit画面(ドロップダウン内)へのリンクがあるのですが、それらのリンク先へ遷移した直後にドロップダウンメニューが動かなくなってしまいます。しかし、ブラウザで再読込(更新)するとドロップダウンメニューが動くようになります。

*やったこと
jsの問題かと思い調べてみたのですが、なかなか適切な資料も見つからず解決には至っていません。

下記にコードを添付いたします。よろしくお願いいたします。

routes.rb

Rails.application.routes.draw do
 root   'static_pages#home'
 get    '/help' => 'static_pages#help'
 get    '/about' => 'static_pages#about'
 get    '/contact' => 'static_pages#contact'
 get    '/signup' => 'users#new'
 get    '/login' => 'sessions#new'
 post   '/login' => 'sessions#create'
 delete '/logout' => 'sessions#destroy'
 resources :users
 resources :account_activations, only: [:edit]
 resources :password_resets,     only: [:new, :create, :edit, :update]
end

_header.html.erb

<nav class="navbar navbar-fixed-top navbar-expand-lg navbar-dark bg-primary">
 <div class="container">
  <a href="/" class="navbar-brand">
   Body-Weight App
  </a>
  <ul class="navbar-nav">
   <% if logged_in? %>
    <li><a  href="/" class="nav-link">Home</a></li>
    <li><a  href="#" class="nav-link">Help</a></li>
    <li  class="dropdown">
      <a href="#" class="nav-link dropdown-toggle" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        Account<span  class="caret"></span>
      </a>
       <div class="dropdown-menu" aria-labelledby="navbarDropdown">
         <a  href="/users/<%= current_user.id.to_s %>/edit" class="dropdown-item">Settings</a>
         <div class="dropdown-divider"></div>
         <a  class="dropdown-item" rel="nofollow" data-method="delete" href="/logout" >Log Out</a>
       </div>
    </li>
  <% else %>
    <li><a  href="#" class="nav-link">Help</a></li>
  <% end %>
</ul>


_head.html.erb

<head>
 <title><%= full_title(yield(:title)) %></title>
 <%= csrf_meta_tags %>

 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
 <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">

 <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
 <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>

application.html.erb

<!DOCTYPE html>
 <html>
  <%= render "layouts/head"%>
  <body>
   <%= render "layouts/header" %>
   <div class="container">
    <%= render "layouts/flash" %>
    <%= yield %>
    <%= render 'layouts/footer' %>
  </div>
  <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
  </body>
</html>

application.js

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
// vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//= require rails-ujs
//= require turbolinks
//= require_tree .
//= require jquery3
//= require popper
//= require bootstrap-sprockets

application.scss

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
 * vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
 * files in this directory. Styles in this file should be added after the last require_* statement.
 * It is generally better to create a new file per style scope.

 */
 @import 'bootstrap';



 $main-blue:#428bca;
 $light-gray:#777777;

 li{
   list-style: none;
 }


 .dropdown-item{
   color:$main-blue;
 }


 .footer{
   margin-top: 100px;
   border-top: 1px solid $main-blue;
   small{
     float:left;
     color:$main-blue;
   }
   ul{
     float:right;
   }
   li{
     float:left;
     margin-left: 15px;
   }
   a{
     color:$main-blue;
   }
 }