views:

33

answers:

3

Ok, so in my rails project. I'm getting this error, any help?

class SearchController < ApplicationController
require 'rubygems'
require 'open-uri'

def index
  @show_info
end
def do_search

    @show = params{:search_term}
    @show = @show["search_term"]
    @url = "http://services.tvrage.com/tools/quickinfo.php?show=#{@show}"

    @sitehtml = open(@url)

    lines = @sitehtml.split("\n")

    @show_info = []
    lines.each do |line|
        line_split = line.split("@")
        @show_info << line_split[1]
    end
end
end

and I keep on getting this error, error (Full Size: http://grab.by/6z6u )

Any help? I don't really understand it.

+2  A: 

StringIO does not have a public split method. So, call string to get the underlying string.

lines = @sitehtml.string.split("\n")
Matthew Flaschen
+1  A: 

The object you're attempting to split isn't a String, it's a StringIO. Try doing .string.split on the offending object instead.

Clint Tseng
There we go! Thanks! I forgot to add the .read on "open(@url)
Rickmasta
+1  A: 

Found out the error! I forgot to put the .read on on "open(@url)" to make it "open(@url).read". Thanks guys!

Rickmasta