Forum: Ruby on Rails Model isn't in the scope when running script/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.
Kfir L. (Guest)
on 2006-04-15 19:25
(Received via mailing list)
Hi,
When running the script/console I can't run the model.
Example:
I have model Probe.
So, running:
Probe.class will not work, because Probe is not loaded.

I tried to build some projects from scratch automatically generated,
but the problem stays.
Any thoughts?

Thanks,
Kfir
Francois GORET (Guest)
on 2006-04-15 19:38
(Received via mailing list)
On Saturday 15 April 2006 22:24, Kfir L. wrote:
> Hi,
> When running the script/console I can't run the model.
> Example:
> I have model Probe.
> So, running:
> Probe.class will not work, because Probe is not loaded.

I think that ActiveRecord loads the models on demand only. So when you
try to
access the "Probe" class, the system will fetch the file named
app/models/probe.rb from the root of your rails application.

Francois
Craig W. (Guest)
on 2006-04-15 19:38
(Received via mailing list)
On Sat, 2006-04-15 at 15:24 +0000, Kfir L. wrote:
> Hi,
> When running the script/console I can't run the model.
> Example:
> I have model Probe.
> So, running:
> Probe.class will not work, because Probe is not loaded.
>
> I tried to build some projects from scratch automatically generated,
> but the problem stays.
> Any thoughts?
----
try entering this in console...

require "app/models/probe.rb"

Craig
This topic is locked and can not be replied to.