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.
E6b040ecc51de500ee5a6f83aa3adc68?d=identicon&s=25 Kfir Lavi (Guest)
on 2006-04-15 17: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
B7aa6f0356566cc801f769c6fc14ba1a?d=identicon&s=25 Francois GORET (Guest)
on 2006-04-15 17:38
(Received via mailing list)
On Saturday 15 April 2006 22:24, Kfir Lavi 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
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-04-15 17:38
(Received via mailing list)
On Sat, 2006-04-15 at 15:24 +0000, Kfir Lavi 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.