title: Sinatra Title Slugs
body: <p>I'm trying to create a slug helper in Sinatra. Here's the code (as seen <a href="http://snippets.dzone.com/posts/show/2384" rel="nofollow noreferrer">here</a>):</p>
  
  <pre><code>helpers do
    def sluggify(title)
    accents = { 
      ['á','à','â','ä','ã'] =&gt; 'a',
      ['Ã','Ä','Â','À'] =&gt; 'A',
      ['é','è','ê','ë'] =&gt; 'e',
      ['Ë','É','È','Ê'] =&gt; 'E',
      ['í','ì','î','ï'] =&gt; 'i',
      ['Î','Ì'] =&gt; 'I',
      ['ó','ò','ô','ö','õ'] =&gt; 'o',
      ['Õ','Ö','Ô','Ò','Ó'] =&gt; 'O',
      ['ú','ù','û','ü'] =&gt; 'u',
      ['Ú','Û','Ù','Ü'] =&gt; 'U',
      ['ç'] =&gt; 'c', ['Ç'] =&gt; 'C',
      ['ñ'] =&gt; 'n', ['Ñ'] =&gt; 'N'
    }
  
    accents.each do |ac,rep|
      ac.each do |s|
        title = title.gsub(s, rep)
      end
    end
  
    title = title.gsub(/[^a-zA-Z0-9 ]/,"")
    title = title.gsub(/[ ]+/," ")    
    title = title.gsub(/ /,"-")
    title = title.downcase
  
  end
  
  end
  </code></pre>
  
  <p>I keep getting this error:</p>
  
  <pre><code>private method `gsub' called for nil:NilClass
  </code></pre>
  
  <p>What exactly is going wrong?</p>