Ruby on rails ruby NameError仅在AWS上未初始化常量
所以我有这些代码Ruby on rails ruby NameError仅在AWS上未初始化常量,ruby-on-rails,ruby,amazon-web-services,amazon-ec2,Ruby On Rails,Ruby,Amazon Web Services,Amazon Ec2,所以我有这些代码 require_relative '../classes/obj/objs.rb' class ObjController < ActionController::Base def get_objs objs = Objs::get_objs render :json => objs end end 在我的流浪环境中,代码运行良好,但当我上传到EC2实例时,它最终会抱怨: NameError in ObjController#get_
require_relative '../classes/obj/objs.rb'
class ObjController < ActionController::Base
def get_objs
objs = Objs::get_objs
render :json => objs
end
end
在我的流浪环境中,代码运行良好,但当我上传到EC2实例时,它最终会抱怨:
NameError in ObjController#get_objs
uninitialized constant ObjController::Objs
两种环境都使用ruby 2.3.1p112(2016-04-26)[x86_64-linux-gnu]
有没有办法解决这个问题 试着在你的
对象前面加上:
这样的前缀
require_relative '../classes/obj/objs.rb'
class ObjController < ActionController::Base
def get_objs
objs = ::Objs::get_objs
render :json => objs
end
end
require_relative'../classes/obj/objs.rb'
类ObjControllerobjs
终止
终止
我觉得require\u relative由于某种原因无法工作
require_relative '../classes/obj/objs.rb'
class ObjController < ActionController::Base
def get_objs
objs = ::Objs::get_objs
render :json => objs
end
end