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

On 4 Jul 2008, at 17:13, Tarscher wrote:

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