[英]ruby NameError uninitialized constant only on AWS
所以我有這些代碼
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]
關於如何解決此問題的任何想法?
嘗試像這樣在Objs
加上::
require_relative '../classes/obj/objs.rb'
class ObjController < ActionController::Base
def get_objs
objs = ::Objs::get_objs
render :json => objs
end
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.