title: Helper - undefined method `gsub' for nil:NilClass
body: <p>I have this function </p>
  
  <p><strong>application_helper.rb</strong></p>
  
  <pre><code>def nl2br(s)
    s.gsub(/\n/, '&lt;br/&gt;')
  end
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>&lt;%= nl2br(@event.rules).html_safe %&gt;
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <blockquote>
    <p>undefined method `gsub' for nil:NilClass</p>
  </blockquote>
  
  <p>At times the content can be <code>nil</code> so which is the best way to handle it?</p>
  
  <p>When I add <code>unless s.nil?</code> in the function I get <code>html_safe undefined method error</code>.</p>