Forum: Ruby on Rails 'NameError: uninitialized constant <MyEntity>' in console

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
47e7a0697beaee00ad63009cb747d676?d=identicon&s=25 Binil Thomas (Guest)
on 2006-05-02 11:58
When I create a new model entity, and try to access it from the Rails
console I get the error:

>> b = Bar.new(:name => 'Some Bar')
NameError: uninitialized constant Bar
        from (irb):1
        from :0

(My model class is called Bar, and is in file app/models/bar.rb)

So, I try to load the model class file, and I run into a more frigtening
error:

>> load 'app/models/bar.rb'
NameError: uninitialized constant ActiveRecord
        from ./app/models/bar.rb:1
        from (irb):3
        from :0

I am using Rails 1.1.2 with Ruby 1.8.4 on Mac OS X 10.4 and MySQL
4.1.18. I get these errors only when I use the Rails console; the model
classes are accessible from the controller and the web pages are painted
properly.

Kindly let me know what is going wrong here.

Thanks,
Binil
47e7a0697beaee00ad63009cb747d676?d=identicon&s=25 Binil Thomas (Guest)
on 2006-05-03 06:11
Removing the line:
 IRB.conf[:LOAD_MODULES] = ['irb/completion']
from my $HOME/.irbrc worked!

Thanks,
Binil

Binil Thomas wrote:
> When I create a new model entity, and try to access it from the Rails
> console I get the error:
>
>>> b = Bar.new(:name => 'Some Bar')
> NameError: uninitialized constant Bar
>         from (irb):1
>         from :0
C9c7a65848f13e2b1a226bbe43bc3672?d=identicon&s=25 Pete Yandell (pete)
on 2006-05-03 19:05
(Received via mailing list)
How are you starting up the Rails console?
47e7a0697beaee00ad63009cb747d676?d=identicon&s=25 Binil Thomas (Guest)
on 2006-05-06 15:18
Pete Yandell wrote:
> How are you starting up the Rails console?
By invoking script/console from the application directory.
This topic is locked and can not be replied to.