Search code examples
ruby-on-railsrubyrakenameerrorrails-generate

Rails generate scaffold -> NameError: uninitialized constant


I've got this stupid thing... I'm sure I just miss something obvious but yahoogling didn't solve the problem.

All I do is

rails new TestApp

and

cd TestApp
rails generate scaffold User name:string age:integer
bundle exec rake db:create
bundle exec db:migrate

which works fine.

But when I go to the IRB, there is no User!

u = User.first
    NameError: uninitialized constant User
    from (irb):3
    from /usr/bin/irb:12:in `<main>'

What's wrong here?

Cheers


Solution

  • Don't use irb, instead:

    rails console
    

    which will have every model of your project imported.