Rails 4, Turbolinks, and jQuery
10 Nov 2013
A likely problem, and one that I ran into on a Rails 4 project, is that the jQuery is not functional until the page is loaded once and then refreshed. This is because turbolinks often breaks javscript libraries such as jQuery. Many library devs are wising up to this and fixing these breaks. However, for now we have to work around these issues. In the case of jQuery the fix is straight forward.
1) Add this to your Gemfile:
2) In your application.js, add this after your jQuery requires and before your turbolink require. For example:
3) Restart your application server and you should now have properly functioning jQuery.