连接到服务时未初始化的常量错误

时间:2013-05-20 13:47:11

标签: ruby-on-rails-3.2 typhoeus

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

现在在另一个Rail应用程序中,我创建了一个简单的Controller来开始调用该服务并使用它的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

根据该错误,我应该将它初始化是什么?

1 个答案:

答案 0 :(得分:1)

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

这有帮助吗?