简体   繁体   English

NameError:未初始化的常量Object :: User

[英]NameError: uninitialized constant Object::User

I searched the other posts that had this issue and could not find one that fixed my particular issue. 我搜索了其他有这个问题的帖子,找不到解决我这个问题的帖子。 My irb is going crazy. 我的伊娃很疯狂。 I am trying to change user roles in my database but I can't even get to my users! 我正在尝试更改数据库中的用户角色,但我甚至无法联系到我的用户!

irb(main):001:0> User.all
NameError: uninitialized constant Object::User
        from (irb):1
        from c:/Ruby192/bin/irb:12:in `<main>'

It was working fine, stopped working, was fine, and now stopped again. 它工作正常,停止工作,很好,现在再次停止。 I have a User model and users added. 我有一个用户模型和用户添加。 I cannot pinpoint the issue. 我无法确定这个问题。 Let me know what code you need to see. 让我知道您需要查看哪些代码。 Thanks! 谢谢!

You should run 你应该跑

ruby script/console # Rails < 3

or 要么

rails c  # Rails 3.x

But not (I believe you've just run this) 但不是(我相信你只是运行这个)

irb

确保您实际使用的是rails console命令,而不是仅在项目文件夹中运行irb

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM