7

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!

Sako Kassabian
  • 145
  • 1
  • 7

2 Answers2

31

You should run

ruby script/console # Rails < 3

or

rails c  # Rails 3.x

But not (I believe you've just run this)

irb
fl00r
  • 82,987
  • 33
  • 217
  • 237
8

Make sure you're actually using the rails console command rather than just running irb in your project folder.

Dylan Markow
  • 123,080
  • 26
  • 284
  • 201
  • Is there a good reason why to use rails console rather then irb? Is it possible to access project model Object via irb? So far I'm getting this "NameError: uninitialized constant ...". – Jonauz Jul 12 '14 at 11:33
  • 1
    `irb` won't load your Rails environment at all, you have to use the rails console for that. – Dylan Markow Jul 12 '14 at 15:13