开发者

Rails not recognizing Ruby's Net module

I am trying to access the contents of the webpage of a target URL using the code:

def fetch_url(url)
    r = Net::HTTP.get_response( URI.parse( url ) )
    (r.is_a?(Net::HTTPSuccess)) ? r.body : nil
end

However, for some reason Rails is not able to identify开发者_运维百科 Net, which is a Ruby module from v. 1.9.2 -- why would this be (I used require 'Net' at the top of my code)?

LoadError in PagesController#home

no such file to load -- Net


It's not require 'Net'. You need this:

require 'net/http'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜