Reputation: 6259
To my Rails Gemfile I added a new gem. It is used like this:
Email::Client
The issue I'm having right now is that I also have a class in my rails app that's called Email
. Now sometimes when I try to initialize it I get the following error:
Email.new # >> undefined method 'new' for Email:Module
Probably because Email
is a Module
in the gem. How can I fix this issue? Is there a way to namespace the gem module? I don't want to rename my Email class.
Upvotes: 2
Views: 613
Reputation: 230296
I don't want to rename the Email-Class.
Yet this is what you'll have to do. Your code is the only thing you control. Either rename/alias it (MyEmail
) or namespace it (MyApp::Email
).
Btw, you got off easy this time. Imagine what'd happen if the other Email
was also a class. Suddenly, all your methods are gone. You add or change a method and your email doesn't see it. This could make for a frustrating debugging session.
Upvotes: 2