【问题标题】:Uninitialized constant error when connecting to a service连接到服务时出现未初始化的常量错误
【发布时间】:2013-05-20 13:47:10
【问题描述】:

我有一个在'http://localhost:4567/order_summary' 上运行的服务,所以当我转到那个地址时,它会向我显示它的 JSON 表示,这正是我想要的。

现在在另一个 Rail 应用程序中,我创建了一个如此简单的控制器,以开始调用该服务并使用其 JSON:

class PharmacyController < ApplicationController
  def index
    result = Typhoeus::Request::get('http://localhost:4567/order_summary')
    @code = result.code
  end
end

但是当我转到http://localhost:3000/pharmacy/ 地址时,我得到了

的错误
NameError in PharmacyController#index

uninitialized constant PharmacyController::Typhoeus

我应该根据那个错误来初始化它是什么?

【问题讨论】:

    标签: ruby-on-rails-3.2 typhoeus


    【解决方案1】:

    我能看到的唯一问题是您的 Gemfile 中可能没有 Typhoeus,或者您不需要它 require 'typhoeus'

    这有帮助吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-20
      • 1970-01-01
      • 1970-01-01
      • 2012-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-13
      相关资源
      最近更新 更多