[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Can't find table with ActiveRecord in different thread.

Juan Zanos

4/3/2009 4:05:00 PM

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.


4 Answers

David Masover

4/3/2009 7:29:00 PM

0

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.

Juan Zanos

4/3/2009 7:36:00 PM

0


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


David Masover

4/3/2009 11:22:00 PM

0

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?

Glenn West

4/8/2009 5:24:00 AM

0

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

http://espaceblogs.blogspot.com/2007/05/update-newly-added-column-...
ion.html

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


On Apr 4, 7:22=A0am, 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 m=
ake
> up Rails. So the Rails list is probably still worth a try.
>
> > Foo.find works in the
> > thread that creates the tables. =A0I get the message "Could not =A0find
> > table 'foos' " =A0in 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?