title: NoMethodError (private method `gsub!' called for Thu Oct 10 11:56:28 UTC 2013:Time):
body: <p>I'm currently using Ruby 1.8.7 (required by hosting provider...moving off soon).</p>
  
  <p>With that aside, I'm getting the following error,</p>
  
  <pre><code>NoMethodError (private method `gsub!' called for Thu Oct 10 11:56:28 UTC 2013:Time):
    app/models/time_tracked.rb:140:in `search'
    app/models/time_tracked.rb:140:in `sort!'
    app/models/time_tracked.rb:140:in `search'
  </code></pre>
  
  <p>The line in question (140) is:</p>
  
  <pre><code>sub.sort! { |x, y| Time.zone.parse(x[1]) &lt;=&gt; Time.zone.parse(y[1]) } if sub.length &gt; 1
  </code></pre>
  
  <p>As I understand it, the error is thrown because I'm trying to parse a time object instead of a string, but I'm unclear on how to correct this.</p>
  
  <p>Any assistance is greatly appreciated.  Thanks!</p>
  
  <p>Update: Cortex's answer resolved the initial question, but implementing it now causes the following on my view,</p>
  
  <pre><code>ActionView::Template::Error (private method `sub!' called for Thu Oct 10 11:56:28 UTC 2013:Time):
      23:&lt;td&gt;&lt;strong&gt;&lt;%= (v.index(item) == 0) ? k : '' %&gt;&lt;/strong&gt;&lt;/td&gt;
      24:&lt;td&gt;&lt;%= item[0] %&gt;&lt;/td&gt;
      25:&lt;td&gt;
      26:&lt;%= DateTime.strptime(item[1], '%Y-%m-%d %H:%M ').in_time_zon e(Time.zone).strftime("%m/%d/%Y %I:%M %p")%&gt;
      27:&lt;/td&gt;
      28:&lt;td&gt;
      29:&lt;%= DateTime.strptime(item[2], '%Y-%m-%d %H:%M:%S').in_time_z
  one(Time.zone).strftime("%m/%d/%Y %I:%M %p")%&gt;
  </code></pre>
  
  <p>Any suggestions?  Thanks!</p>