Sreeraj Chundayil
Sreeraj Chundayil

Reputation: 5859

NameError: uninitialized constant className

I am getting error in irb

NameError: uninitialized constant Student

for Student.new or whatever model operations are there.

But in rails it gives no error and it works fine. What would be the reason?

This error only happens in Windows, same code I have in Linux and there it works fine.

What makes the difference here?

Upvotes: 0

Views: 304

Answers (2)

Saad Saeed
Saad Saeed

Reputation: 63

rails c

Create new tab in terminal. Here you may work with modals. Like CRUD operations.

But make sure your terminal must pointing in rails working directory before trying rails c command ...

Upvotes: 0

Andrey Deineko
Andrey Deineko

Reputation: 52357

irb has nothing to do with your rails project.

What you want instead is to run

rails console

from within your rails project directory. Here you have access to everything defined within the application - Rails loads everything automatically.

Upvotes: 5

Related Questions