Multiple models one form and a one-to-one relationship

Hi!

I've got a not so unfamiliar multiple models in one form problem. Due to the complex forms railscast I've got it up and running for a one-to- many relationship but now I have a one-to-one relationship and I didn't get it done.

Here is my code, perhaps someone can take a look and give me a hint what's wrong. I put what is going wrong into the code where I think it is belonging to. And I don't know if it matters but I'm running Rails 2.1.1.

In a has_one/belongs_to association, I don't think you need the user= method. What happens if you take it out completely?

Try self.build_user(:name=>attributes) , name or whatever the column is.

Without the user method in the subscription model I get the following error:

User(#17369790) expected, got HashWithIndifferentAccess(#2700040)

I've changed the user method:

def user=(attributes)   attributes.each do |attribute|     self.build_user(attribute.first => attribute.last)   end end

I get no error and the subscripton model is saved, but not the user model.

These are my parameters:

..."subscription"=>{   "user"=>{     "name"=>"vorname",     "city"=>"ort",     "postal_code"=>"plz",     "street"=>"straße",     "phone"=>"telefon",     "c_o"=>"c/o (optional)",     "surname"=>"nachname",     "comment"=>"kommentar (optional)",     "email"=>"e-mail"   } }...

For me they are not looking that bad.