Has_one relationship problem


#1

I was wondering if anyone could see the error in this littte application

I have two models, User and Selection

Selection is an extension of the User model

so in the User model I have a has_one :selection
and in Selection I have a belongs_to :user

in my views, i cannot get @user.selection to work but @user works fine.

http://www.rafb.net/paste/results/GSBt1e61.html

Thanks,

r.b


#2

What you describe should be fine, so the problem must be somewhere else.
Do
you have your selection table setup with a user_id field?

matt


#3

yes, the selections table has a user_id field


#4

One more thing to check is to make sure that the user actually has a
selection assigned to it. Do this in the controller-

@user.selection = Selection.new


#5

is that necessary?

I was under the assumption that the model relationships would handle
the collection?