I built a library on “lib” rails directory. The structure of library is something like this:
lib/insurance/broker/fake_broker.rb
the class looks like the following example:
module Insurance
module Broker
class FakeBroker
def initialize(user_id, user_secret)
@user_id = user_id
@user_secret = user_secret
end
end
end
end
So, in my result_controller I’m doing this:
require 'insurance/broker/fake_broker'
def show
broker = Insurance::Broker::FakeBroker.new(1234,1234)
end
but Rails is returning this error:
Insurance is not a module
What’s wrong here?
Ruby is telling you that it found an
Insurance, but it is not a module.Perhaps you already have defined an
Insuranceclass?Depending on the surrounding code it might help if you “reset” the namespace by prepending a double colon: