In my app I have
class User
include User::Foo
end
User::Foo
is defined in app/models/user/foo.rb
Now I'm using a library that defines its own Foo
class. I'm getting this error:
warning: toplevel constant Foo referenced by User::Foo
User
only refers to Foo
with the full path, User::Foo
, and Foo
never actually refers to Foo
.
What's going on?
update: just remembered I had the same problem before, seen here in question 1: How do I refer to a submodule's "full path" in ruby?
The message says: the only definition it found was at the top level. This is obviously suspicious since you went to the trouble of qualifying the name.
There isn't a good way to say you want a different ::User. It's a class and ruby will look for a definition there, then at the top level. You need to somehow specify the module without referencing your class.
One way to fix this:
module Other
class User
include ::User::Foo
end
end
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