Domanda

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

È stato utile?

Soluzione

Don't use irb, instead:

rails console

which will have every model of your project imported.

Altri suggerimenti

You haven't created a user and you are using plain old irb instead of rails console.

open a rails console and try:

User.create(:name => "Jimmy", :age => 14)

Then try

u = User.first
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top