Forum: Ruby Can't find table with ActiveRecord in different thread.

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.
01cd7a5d8751789819701518f3fe6ffa?d=identicon&s=25 Juan Zanos (Guest)
on 2009-04-03 18:07
(Received via mailing list)
Hi, I'm not sure if this is a ruby question or a rails question.  If
I create an ActiveRecord table in one thread I can't find it in
another thread, which I'd like to be able to do.   Interestingly,
this behavior seems to be dependent on whether all the code is in a
single file or in separate ones, which seems odd to me.
1bc63d01bd3fcccc36fb030a62039352?d=identicon&s=25 David Masover (Guest)
on 2009-04-03 21:30
(Received via mailing list)
On Friday 03 April 2009 11:05:21 Juan Zanos wrote:
> Hi, I'm not sure if this is a ruby question or a rails question.  If
> I create an ActiveRecord table

Rails question.

> in one thread I can't find it in
> another thread, which I'd like to be able to do.

If you have a question about threading, that _might_ be a Ruby question.
But
the way Rails deals with threading is certainly a Rails question.

But while you're here... Why do you need this? Normally, tables are
created
inside a migration, after which you restart the server.
01cd7a5d8751789819701518f3fe6ffa?d=identicon&s=25 Juan Zanos (Guest)
on 2009-04-03 21:36
(Received via mailing list)
On 3 avr. 09, at 15:29, David Masover wrote:

> question. But
> the way Rails deals with threading is certainly a Rails question.
>
> But while you're here... Why do you need this? Normally, tables are
> created
> inside a migration, after which you restart the server.
>

I'm not using rails, just ActiveRecord.   Foo.find works in the
thread that creates the tables.  I get the message "Could not  find
table 'foos' "  in other threads.
1bc63d01bd3fcccc36fb030a62039352?d=identicon&s=25 David Masover (Guest)
on 2009-04-04 01:23
(Received via mailing list)
On Friday 03 April 2009 14:35:50 Juan Zanos wrote:
> I'm not using rails, just ActiveRecord.

Which is part of Rails. It's one of three or four major components that
make
up Rails. So the Rails list is probably still worth a try.

> Foo.find works in the
> thread that creates the tables.  I get the message "Could not  find
> table 'foos' "  in other threads.

Is it possible to create the table before loading the model in any
thread?

Are you sure you've committed the transaction that had that "create
table"
command in it? Are you sure that's all done before the other threads try
the
find?
A93363196f047ab4a7c4dab02e90091d?d=identicon&s=25 glennswest (Guest)
on 2009-04-08 07:24
(Received via mailing list)
This is common in migrations.
You need to tell the model that the its been modified.

http://espaceblogs.blogspot.com/2007/05/update-new...

And you should make sure that its actually created, otherwise your
going to have a race condition.
This topic is locked and can not be replied to.