Sushant Rao
Sushant Rao

Reputation: 484

Using require in a module -- Rails

This seems fairly trivial but is giving me hella grief!

I have a module in the lib folder.

require 'net/http'
module Weather

  def get_response
    NET::HTTP.get_response(URI.parse 'someURL').body
  end

end 

The controller.

class SunController < ApplicationController
include Weather

  def show  
    logger.debug get_response
  end
end 

config/Application.rb

config.autoload_paths += %W(#{config.root}/lib)

And I get this error

uninitialized constant Weather::NET

I know the module is loaded correctly. What am I doing wrong?

Upvotes: 0

Views: 702

Answers (1)

user1454117
user1454117

Reputation:

The class is Net::HTTP not NET::HTTP.

Upvotes: 3

Related Questions