Can't find table with ActiveRecord in different thread

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.

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.

···

On Friday 03 April 2009 11:05:21 Juan Zanos wrote:

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.

···

On 3 avr. 09, at 15:29, David Masover wrote:

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.

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?

···

On Friday 03 April 2009 14:35:50 Juan Zanos wrote:

This is common in migrations.
You need to tell the model that the its been modified.

And you should make sure that its actually created, otherwise your
going to have a race condition.

···

On Apr 4, 7:22 am, David Masover <ni...@slaphack.com> wrote:

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?