saving record and it's association

Hi all,

I have a user that has one activation.

When a user is created I want to generate an activation key

I tried in the create usercontroller
    @user = User.new(params[:user])
    @user.activation << Activation.new()

I get:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.<<

I want to save the user and it's association (activation). How can I
do this?

thanks
Stijn

Hi all,

I have a user that has one activation.

When a user is created I want to generate an activation key

I tried in the create usercontroller
   @user = User.new(params[:user])
   @user.activation << Activation.new()

I get:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.<<

I want to save the user and it's association (activation). How can I

Assuming activation is a singular association (ie not a has many) then
you should be using = not <<

Fred