[解决:请参阅下面我的评论]红宝石宝石与Acroynym在名称
我创建了一个Ruby宝石连接到我的应用程序的API:my_app_api。我想这样使用它:MyAppAPI::Foo.bar()
。不过,我得到:
NameError: uninitialized constant MyAppAPI
我知道标准方法来调用/名,这将是MyAppApi::Foo.bar()
,但我更愿意保持与缩写类的命名规则。我如何指定/加载模块?
仅供参考,类看起来是这样的:
module MyAppAPI
class Foo < ActiveResource::Base
extend MyAppAPI
self.site = 'http://localhost:3000/api/'
self.format = :json
class << self
def bar
return 'huzzah!'
end
end
end
end
而且my_app_api.rb
文件看起来像这样:
require "rubygems"
require 'active_resource'
require 'my_app_api/foo'
看起来这实际上是RVM问题的结果(我在全局gemset中安装了gem的旧版本,而且没有安装)。感谢您的想法! – ideaoforder