title: Ruby parsing XML: no implicit conversion of String into Integer
body: <p>I'm working on a Sinatra application that pulls in a list of dates through an XML file and then creates an hash of all the dates.</p>
  
  <p>I'm running into a strange issue that's happening when I'm pulling the id and assigning it to a variable. </p>
  
  <p>The error I'm getting is:
  <strong>no implicit conversion of String into Integer</strong> and it's being thrown on the <code>event_date_id = event_date["date_id"]</code> line. I have almost identical method in my code and it's working just fine. When I <code>puts event_date['date_id']</code> it gives me the correct numerical date_id. </p>
  
  <p>Just in case it helps, the class of the event_date['date_id'] is REXMLUtiliyNodeString, same as the id field in the other method. If I try to <code>event_date['date_id'].to_i</code> it gives breaks at that point.</p>
  
  <pre><code>def get_dates(event_id)
  
  url = "some_url_to_some_xml"
  puts '==================='
  puts "Pulling in #{url}"
  puts '==================='
  date_xml = Crack::XML.parse(open(url))
  
  dates = {}
  
  date_xml['document']['date'].each do | event_date |
  
    event_date_id = event_date['date_id']
  
    single_date = {
      'date_id' =&gt; event_date_id,
      'date_start' =&gt; event_date['datestart'],
      'date_end' =&gt; event_date['dateend'],
      'date_live' =&gt; event_date['live'],
      'time_start' =&gt; event_date['timestart'],
      'time_end' =&gt; event_date['timestart'],
      'date_available' =&gt; event_date['date_available']
    }
  
    dates.merge!( event_date_id =&gt; single_date )
  
  end
  
  return dates
  
  end
  </code></pre>
  
  <p>Here is the xml format:</p>
  
  <pre><code>&lt;document&gt;
      &lt;date&gt;
          &lt;date_id&gt;881908&lt;/date_id&gt;
          &lt;live&gt;y&lt;/live&gt;
          &lt;datestart&gt;2017-08-14&lt;/datestart&gt;
          &lt;dateend&gt;2017-08-15&lt;/dateend&gt;
          &lt;timestart&gt;13:00&lt;/timestart&gt;
          &lt;timeend&gt;0:00&lt;/timeend&gt;
          &lt;date_available&gt;10000&lt;/date_available&gt;
      &lt;/date&gt;
  &lt;document&gt;
  </code></pre>
  
  <p>I have a feeling this is something really simple but I'm wracking my brains trying to figure it out. If anyone could shed some light on this, I'd definitely appreciate it.</p>
  
  <p><strong>Edit 1: When I run the code in irb, it does indeed work without error. Somewhere, somehow it seems Sinatra, Rack or Shotgun are getting in the way.</strong></p>