Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"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.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.

like image 575
Rickmasta Avatar asked May 01 '26 05:05

Rickmasta


2 Answers

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

like image 156
issa marie tseng Avatar answered May 03 '26 19:05

issa marie tseng


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

lines = @sitehtml.string.split("\n")
like image 38
Matthew Flaschen Avatar answered May 03 '26 17:05

Matthew Flaschen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!