Search code examples
ruby-on-rails-3.2typhoeus

Uninitialized constant error when connecting to a service


I have a service that is running on 'http://localhost:4567/order_summary' so when I go to that address it shows me the JSON representation of it which is what I want.

Now in another Rail application I created a Controller as simple as this to start working on calling that service and working with its JSON:

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

but when I go to http://localhost:3000/pharmacy/ address I get the error of

NameError in PharmacyController#index

uninitialized constant PharmacyController::Typhoeus

What is it that I should initilaize it based on that error?


Solution

  • The only issue I can see is that you might not have Typhoeus in your Gemfile or you didn't require it require 'typhoeus'

    Does that help?