# Session/marshalling

**URL:** <https://www.ruby-forum.com/t/session-marshalling/148322>\
**Category:** Rails\
**Created:** [September 11, 2008, 6:54pm UTC](https://www.ruby-forum.com/t/session-marshalling/148322 "2008-09-11T18:54:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wurdalag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/6f9a4e/32.png) [@wurdalag](https://www.ruby-forum.com/u/wurdalag)\
**Post date:** [September 11, 2008, 6:54pm UTC](https://www.ruby-forum.com/t/session-marshalling/148322/1 "2008-09-11T18:54:56Z")

</div>

I have the following problem with marshalling/saving a model to session.  
I have 4 models: User, Profile, Customer, Membership. Membership belongs  
to the other three models, and User, Profile and Customer all have a  
has\_one :through =\> :memberhsip association to each other. Now I have a  
registration process over several steps, including the creation of all 4  
models. Partially the validation of the models is dependent on the other  
models. So i need to have them linked to each other from the beginning  
of the registration process. Also I need them to be saved to session.

Now the problem is, if I do this:

@membership = Membership.new  
@profile = @membership.build\_profile  
@customer = @membership.build\_customer  
@customer.profile = @profile # \<= thatâ€™s the problem

And then try to save @customer in the session:

session[:customer] = @customer

There is a 500 internal server error:

NoMethodError (undefined method `marshal\_dump’ for #Class:0x2162504)

And that is only if I establish the link between two has\_one :through  
associations. For example between @profile and @customer, or @customer  
and @user.

Do you habe any idea, how i could solve this problem? I greatly  
apreciate any help.
