所以我有这些代码
require_relative '../classes/obj/objs.rb'
class ObjController < ActionController::Base
def get_objs
objs = Objs::get_objs
render :json => objs
end
end
和objs.rb
module Objs
def Objs.get_objs
objs = {
1 => 2,
}
return objs
end
end
在我的流浪者环境中代码运行正常,但是当我上传到我的EC2实例时,它最终抱怨:
NameError in ObjController#get_objs
uninitialized constant ObjController::Objs
这两个环境都使用ruby 2.3.1p112(2016-04-26)[x86_64-linux-gnu]
有关如何解决此问题的任何想法?
答案 0 :(得分:0)
尝试为您的Objs
添加前缀::
,如此...
require_relative '../classes/obj/objs.rb'
class ObjController < ActionController::Base
def get_objs
objs = ::Objs::get_objs
render :json => objs
end
end