title: How to parse data from Ruby array?
body: <p>I'm using watir-webdriver to scrape data from a website. When I try to import the data into the DB I get the error "can't cast Array to text".</p>
  
  <pre><code>def get_event_details(url)
      headless = Headless.new
      headless.start
      b = Watir::Browser.start "http://example.com"
      @event = event ={}
      if event_detail = get_html_from_url(url)
        event["title"] = b.spans(:class =&gt; "classname").collect &amp;:text
        event["source_url"] = b.split("&amp;year")[0] if b.include?("&amp;year") rescue b
        event["timezone"] = 'HST'
        event
      end
      puts event
      return event
      b.close
      headless.destroy
  end
  </code></pre>
  
  <p>The data being imported looks something like this:</p>
  
  <pre><code>{"title"=&gt;["1", "2", "3"]}
  </code></pre>
  
  <p>After I added this bit of code</p>
  
  <pre><code>event["title"] = b.spans(:class =&gt; "classname").collect.map { |i| "'" + i.text + "'" }.join(", ")
  </code></pre>
  
  <p>I'm no longer getting the error but every single title is being inserted to the same column in the DB. The data being imported now looks like this:</p>
  
  <pre><code>{"title"=&gt;"'1', '2', '3'"}
  </code></pre>
  
  <p>I'm not sure how to go about fixing this. Any ideas?</p>