Rails has a [`parameterize` method](http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-parameterize) for exactly this situation. `heading.parameterize` should be all you need.