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 Insurance
class?
Depending on the surrounding code it might help if you "reset" the namespace by prepending a double colon:
broker = ::Insurance::Broker::FakeBroker.new(1234,1234)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With