Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing third party libraries' non-existent classes in Rails console references top level constant #22176

Closed
d0minicw0ng opened this issue Nov 4, 2015 · 1 comment

Comments

@d0minicw0ng
Copy link

In my Rails (4.2.4) app, I have a model called Comment and I am seeing this strange behavior in the Rails console.

[1] pry(main)> require 'kramdown'
=> true
[2] pry(main)> Kramdown::Comment
=> Comment (call 'Comment.connection' to establish a connection)
[3] pry(main)> Kramdown::Comment
NameError: uninitialized constant Kramdown::Comment

    Did you mean? Kramdown::Element
                  Kramdown::Document
                  Carmen
                  Client
                  Comment

from (pry):3:in `<main>'
[1] pry(main)> Maildown::Comment
=> Comment (call 'Comment.connection' to establish a connection)
[2] pry(main)> Maildown::Comment
NameError: uninitialized constant Maildown::Comment

    Did you mean? Carmen
                  Client
                  Comment

from (pry):2:in `<main>'
[1] pry(main)> Money::Comment
=> Comment (call 'Comment.connection' to establish a connection)
[2] pry(main)> Money::Comment
(pry):2: warning: toplevel constant Comment referenced by Money::Comment
=> Comment (call 'Comment.connection' to establish a connection)

Maildown (module), Kramdown (module) and Money (class) do not have a class called Comment, and when I call it for the first time, it goes to my Rails model.

However, if I try to do it with a different model, it has a different behavior.

[1] pry(main)> require 'kramdown'
=> true
[2] pry(main)> Kramdown::User
NameError: uninitialized constant Kramdown::User

    Did you mean? User

from (pry):2:in `<main>'
[1] pry(main)> Maildown::User
NameError: uninitialized constant Maildown::User

    Did you mean? User

from (pry):1:in `<main>'
[1] pry(main)> Money::User
(pry):1: warning: toplevel constant User referenced by Money::User
=> User (call 'User.connection' to establish a connection)
@d0minicw0ng
Copy link
Author

Sorry, just found an old issue #6931

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant