This is a simple example of action specific javascript. It also allows you to pass data to JS from inside rails controllers. Works with Turbolinks 5 (not required).
Add the files below to your project, then insert <%= insert_javascript_hook %>
somewhere in the footer of your layout.
You'll need these gems:
gem 'jquery-rails'