RailheadAutoformat is a Ruby on Rails plugin that automatically cleans up input fields.
Add to your Gemfile:
gem 'railhead_autoformat'
It works fully automatically, but there is one options to modify the default behavior.
auto_format except: [:title]
Copyright © 2012-2015 Bence Nagy (bence.nagy@gmail.com), released under the MIT license.