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.