炸蝦碎碎念。

[Notes, GNU/Linux, Open Source, Ruby on Rails, Computer Science, Archlinux]

[Rails] jQuery in Rails 4 -- Uninstalling Turbolinks

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.

  1. Remove gem 'turbolinks' in Gemfile
  2. Run bundle install
  3. Remove //=require turbolinks in app/assets/javascripts/application.js
  4. Remove all code related to turbolinks in the include tags in your layout pages.

There are other workarounds but this is the simplest.

Reference: How to disable Turbolinks in Rails 4

Comments