Has_one relationship problem

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.




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


yes, the selections table has a user_id field

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

is that necessary?

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs