2013-03-05 25 views
0

這似乎相當瑣碎的,但給我海拉的悲傷!使用模塊需要 - Rails的

我有lib文件夾中的模塊。

require 'net/http' 
module Weather 

    def get_response 
    NET::HTTP.get_response(URI.parse 'someURL').body 
    end 

end 

控制器。

class SunController < ApplicationController 
include Weather 

    def show 
    logger.debug get_response 
    end 
end 

的config/application.rb中

config.autoload_paths += %W(#{config.root}/lib) 

而且我得到這個錯誤

uninitialized constant Weather::NET 

我知道模塊加載正確。我究竟做錯了什麼?

+0

將::網前。 – 2013-03-05 20:39:56

+0

沒有定義'你的自動加載路徑lib'明確。它將在應用程序啓動時加載。 – AnkitG 2013-03-05 20:40:26

回答

3

類是Net::HTTPNET::HTTP

+0

真棒!謝謝。我知道這很愚蠢。 – 2013-03-06 06:55:30