"private method `split' called for"
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.tvrag开发者_如何学编程e.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,
(Full Size: http://grab.by/6z6u )Any help? I don't really understand it.
The object you're attempting to split isn't a String, it's a StringIO. Try doing .string.split
on the offending object instead.
StringIO does not have a public split
method. So, call string
to get the underlying string.
lines = @sitehtml.string.split("\n")
Found out the error! I forgot to put the .read on on "open(@url)" to make it "open(@url).read". Thanks guys!
精彩评论