While working on the Rails project, I have problems using jQuery. The problem is from the Turbolink, when you click a link, it uses AJAX to get content from Rails without reloading page. So the $(document).ready() in jQuery won’t work. It can be fixed simply by uninstalling the Turbolinks gem.
- Remove
gem 'turbolinks'inGemfile - Run
bundle install - Remove
//=require turbolinksinapp/assets/javascripts/application.js - Remove all code related to
turbolinksin the include tags in your layout pages.
There are other workarounds but this is the simplest.
Reference: How to disable Turbolinks in Rails 4