Integrate JQuery ScrollToFixed plugin into Rails.
You can check the official documentation here.
NOTE: you have to install jquery-rails gem to use this gem.
Add this line to your application's Gemfile:
gem 'jquery-scrolltofixed-rails'
And then execute:
$ bundle
Or install it yourself as:
$ gem install jquery-scrolltofixed-rails
Copy:
//=require jquery-scrolltofixed-rails
In your:
assets/javascripts/application.js
Just create a PR.
The gem is available as open source under the terms of the MIT License.