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
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 On 1/12/06, Raja Bhatia <raja.bhatia@gmail.com> wrote:> > 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 > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060112/78aa47af/attachment.html
yes, the selections table has a user_id field On 1/12/06, matthew clark <winescout@gmail.com> wrote:> 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 > > > On 1/12/06, Raja Bhatia <raja.bhatia@gmail.com> wrote: > > > > 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 > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
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 On 1/12/06, Raja Bhatia <raja.bhatia@gmail.com> wrote:> > yes, the selections table has a user_id field > > > On 1/12/06, matthew clark <winescout@gmail.com> wrote: > > 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 > > > > > > On 1/12/06, Raja Bhatia <raja.bhatia@gmail.com> wrote: > > > > > > 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 > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060112/cb779b3b/attachment.html
is that necessary? I was under the assumption that the model relationships would handle the collection? On 1/12/06, matthew clark <winescout@gmail.com> wrote:> 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 > > On 1/12/06, Raja Bhatia <raja.bhatia@gmail.com> wrote: > > yes, the selections table has a user_id field > > > > > > On 1/12/06, matthew clark <winescout@gmail.com> wrote: > > > 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 > > > > > > > > > On 1/12/06, Raja Bhatia <raja.bhatia@gmail.com> wrote: > > > > > > > > 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 > > > > _______________________________________________ > > > > Rails mailing list > > > > Rails@lists.rubyonrails.org > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >