Forum: Ruby save object reference in db?

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.
E3513c4edd6810bb4b9914b58da2a2c3?d=identicon&s=25 Jamal Soueidan (jamal)
on 2008-10-27 13:16
Hi everyone,

I want to ask if it's possible to save object reference in database for
later use?

Regards,
Jamal
E0d864d9677f3c1482a20152b7cac0e2?d=identicon&s=25 Robert Klemme (Guest)
on 2008-10-27 14:14
(Received via mailing list)
2008/10/27 Jamal Soueidan <jamal@soueidan.com>:
> I want to ask if it's possible to save object reference in database for
> later use?

No, not directly.  How should that work?

You either need an OR mapper (for example ActiveRecord) or you store
complete object graphs serialized (via Marshal in a BLOB or YAML in a
CLOB).

Cheers

robert
753dcb78b3a3651127665da4bed3c782?d=identicon&s=25 Brian Candler (candlerb)
on 2008-10-27 15:14
Robert Klemme wrote:
> 2008/10/27 Jamal Soueidan <jamal@soueidan.com>:
>> I want to ask if it's possible to save object reference in database for
>> later use?
>
> No, not directly.  How should that work?

Well, technically it *is* possible to save object references - see
weakref.rb for an implementation.

But this is almost certainly not what the OP wants (since those object
references won't survive garbage collection, or application restart)
E0d864d9677f3c1482a20152b7cac0e2?d=identicon&s=25 Robert Klemme (Guest)
on 2008-10-27 16:51
(Received via mailing list)
2008/10/27 Brian Candler <b.candler@pobox.com>:
> Robert Klemme wrote:
>> 2008/10/27 Jamal Soueidan <jamal@soueidan.com>:
>>> I want to ask if it's possible to save object reference in database for
>>> later use?
>>
>> No, not directly.  How should that work?
>
> Well, technically it *is* possible to save object references - see
> weakref.rb for an implementation.

Hey, normally *I* am supposed to be the nitpick!  What's the point in
storing something that you cannot reasonably retrieve?  This is only
useful for a WOM. *gg*

> But this is almost certainly not what the OP wants (since those object
> references won't survive garbage collection, or application restart)

Exactly!

Kind regards

robert
This topic is locked and can not be replied to.