Can't find table with ActiveRecord in different thread.

J

Juan Zanos

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.
 
D

David Masover

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.
 
J

Juan Zanos

Rails question.


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. Foo.find works in the
thread that creates the tables. I get the message "Could not find
table 'foos' " in other threads.
 
D

David Masover

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,175
Messages
2,570,947
Members
47,498
Latest member
yelene6679

Latest Threads

Top