title: undefined method `match' for nil:NilClass
body: <p>I am trying to remove from a  text box anything that is not between <code>[]</code>. This works for <code>edit</code> record form:</p>
  
  <pre><code>&lt;%= f.text_field :transport_relay, :value =&gt; f.object.transport_relay.match(/\[(.*?)\]/)[1]  %&gt;
  </code></pre>
  
  <p>but when I try to create a <code>new</code> record, it displays <code>"undefined method `match' for nil:NilClass"</code> error as expected, as the new record has noting to match with. How do I handle this problem?</p>
  
  <p>I tried several solutions, i.e., this:</p>
  
  <pre><code>&lt;%= f.text_field :transport_relay, :value =&gt; f.object.transport_relay.match(/\[(.*?)\]/)[1]  if f.object.transport_relay %&gt;
  </code></pre>
  
  <p>solved the error problem, but also removed the input text box in the process.</p>