I have the following model in a Rails application:
class Comment
class Digest
end
end
When I try to load it in the console, I get:
$ rails c
Loading development environment (Rails 4.1.2)
irb(main):001:0> Comment::Digest
(irb):1: warning: toplevel constant Digest referenced by Comment::Digest
=> Digest
irb(main):002:0> require "comment/digest"
=> true
irb(main):003:0> Comment::Digest
=> Comment::Digest
If I change the name Digestto Other, it works fine. The class is designed for digest notifications, and I would like to keep the name if I can get around it relatively easily.
class Comment
class Other
end
end
irb(main):003:0> Comment::Other
=> Comment::Other
If I add an initializer to load the model, it works fine:
require "comment"
require "comment/digest"
I understand that it does not load using const_getb / c. Digest module already exists. Just not sure what the best way to handle this.
source
share