# Store objects in sessions

**URL:** <https://www.ruby-forum.com/t/store-objects-in-sessions/190240>\
**Category:** Rails\
**Created:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/store-objects-in-sessions/190240 "2010-06-17T16:22:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marmolin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71e660/32.png) [@marmolin](https://www.ruby-forum.com/u/marmolin)\
**Post date:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/store-objects-in-sessions/190240/1 "2010-06-17T16:22:28Z")

</div>

I have a non active revord object and i have to find an instance of  
that object between requests  
I have tried to save it in session but as the object uses Libxml i got  
the error no marshall dump exists  
I cannot make an active revord object as it is an object with no  
attributes just methods  
My solution is that not use an instance just The Class but then the  
code becomes rather complex  
So how to find an instance of that object between requests

Any ideas would be appreciated

Skickat från min iPhone

---

<div class="post-metadata">

**Author:** ![marmolin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71e660/32.png) [@marmolin](https://www.ruby-forum.com/u/marmolin)\
**Post date:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/store-objects-in-sessions/190240/2 "2010-06-17T16:22:36Z")

</div>

On Mon, Jun 14, 2010 at 11:10 PM, Hans M.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I have a non active revord object and i have to find an instance of that  
> object between requests  
> I have tried to save it in session but as the object uses Libxml i got the  
> error no marshall dump exists  
> I cannot make an active revord object as it is an object with no attributes  
> just methods  
> My solution is that not use an instance just The Class but then the code  
> becomes rather complex  
> So how to find an instance of that object between requests

If it has “no attributes”, then every instance is identical, yes? So why  
not instantiate a new one when you need it?

I guess I’m having a hard time understanding your use case.

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan

---

<div class="post-metadata">

**Author:** ![marmolin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71e660/32.png) [@marmolin](https://www.ruby-forum.com/u/marmolin)\
**Post date:** [June 17, 2010, 4:27pm UTC](https://www.ruby-forum.com/t/store-objects-in-sessions/190240/3 "2010-06-17T16:27:01Z")

</div>

My fault I did not realized that  
My use vase is that I refactored some code as à service object.  
That object is a parser and I would like to use the initialize methods  
to  
simplify the use of instance variables in different methods  
As i understand your suggestion it would be ok to call a new instance  
in each controller action

On 15 Juni, 16:16, Hassan S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
