"private` split 'method called "

Ok, so in my rails project. I get 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 getting this error, error (Full size: http://grab.by/6z6u )

Any help? I do not understand this.

+3
source share
3 answers

The object you are trying to split is not a string, but a string. Instead, try to do .string.spliton the offending object.

+2
source

StringIO does not have a public method split. So call stringto get the baseline.

lines = @sitehtml.string.split("\n")
+2
source

! .read "open (@url)", " (@url).read". , !

+1
source

Source: https://habr.com/ru/post/1766604/


All Articles