Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在模块中使用require——Rails_Ruby On Rails_Ruby On Rails 3_Module_Require - Fatal编程技术网

Ruby on rails 在模块中使用require——Rails

Ruby on rails 在模块中使用require——Rails,ruby-on-rails,ruby-on-rails-3,module,require,Ruby On Rails,Ruby On Rails 3,Module,Require,这似乎很琐碎,但却给了我极大的悲痛 我在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

这似乎很琐碎,但却给了我极大的悲痛

我在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 
我得到了这个错误

uninitialized constant Weather::NET

我知道模块加载正确。我做错了什么

类是
Net::HTTP
not
Net::HTTP
类是
Net::HTTP
not
Net::HTTP

不要在自动加载路径中明确定义
lib
。它将在应用程序启动时加载。不要在自动加载路径中明确定义
lib
。它将在应用程序启动时加载。
uninitialized constant Weather::NET