nil的未定义方法'path':使用chargify_api_ares gem的NilClass

Rub*_*oob 5 chargify ruby-on-rails-3

我觉得这应该是一个简单的问题,但我正在试着追踪它.我已经安装了chargify_api_ares gem,但是甚至不能做基本的事情

Chargify::Subscription.create
Run Code Online (Sandbox Code Playgroud)

因为我得到这个路径错误.我觉得这肯定是一个宝石问题,但不知道从哪里开始.

更新:bundle show chargify_api_ares显示正确的路径,我只是以某种方式无法访问它.还在尝试随机环境相关的事情.

看起来这是问题的根源,在active_resource\base.rb中:

# Gets the \prefix for a resource's nested URL (e.g., <tt>prefix/collectionname/1.json</tt>)
      # This method is regenerated at runtime based on what the \prefix is set to.
      def prefix(options={})
        default = site.path
        default << '/' unless default[-1..-1] == '/'
        # generate the actual method based on the current site path
        self.prefix = default
        prefix(options)
      end
Run Code Online (Sandbox Code Playgroud)

据我了解,Chargify.subdomain应该设置site.path,但我还不了解activeresource还不知道发生了什么,并将继续挖掘.

com*_*sis 0

我也有同样的问题。我在控制台执行了以下命令

Chargify.configure do |c|
  c.api_key   = "<<api_key>>"
  c.subdomain = "<<subdomain>>"
end
Run Code Online (Sandbox Code Playgroud)

之后,执行任何 Chargify 控制台命令都会顺利进行。