Heya everyone! I am quite new to Rails and I am reading AWDwR. I am at Task E "Check Out!". I understand it quite well, but I have a problem with the last playground exercise: Add a Table which contains the payment types. All goes well, but I am not sure whether I should use has_many or has_one(as in the Playground wiki at http://wiki.pragprog.com/cgi-bin/wiki.cgi/PT-E-3). I use the following: class Order < ActiveRecord::Base belongs_to :pay_type ... end and class PayType < ActiveRecord::Base has_many :orders ... end Is this right? Or should I use has_one instead of belongs_to in Order? An order references to one PayType, Order has one PayType. I am confused, please help me. Regards, Thomas --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Heya everyone! > I am quite new to Rails and I am reading AWDwR. I am at Task E "Check > Out!". I understand it quite well, but I have a problem with the last > playground exercise: Add a Table which contains the payment types. > All goes well, but I am not sure whether I should use has_many or > has_one(as in the Playground wiki at > http://wiki.pragprog.com/cgi-bin/wiki.cgi/PT-E-3). > > Or should I use has_one instead of belongs_to in Order? An order > references to one PayType, Order has one PayType. > I am confused, please help me.This might be useful to help illustrate things... http://mboffin.com/stuff/ruby-on-rails-data-relationships.png --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
2007/8/21, Philip Hallstrom <rails-SUcgGwS4C16SUMMaM/qcSw@public.gmane.org>:> > This might be useful to help illustrate things... > > http://mboffin.com/stuff/ruby-on-rails-data-relationships.png >Ah! Thank you! So just to make it clear: An Order belongs_to a PayType because the Orders table has an pay_type_id. And PayType has_many Orders because, many Orders reference to the pay_types table. Right? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> 2007/8/21, Philip Hallstrom <rails-SUcgGwS4C16SUMMaM/qcSw@public.gmane.org>: >> >> This might be useful to help illustrate things... >> >> http://mboffin.com/stuff/ruby-on-rails-data-relationships.png >> > > Ah! Thank you! So just to make it clear: An Order belongs_to a PayType > because the Orders table has an pay_type_id. And PayType has_many > Orders because, many Orders reference to the pay_types table. Right?Seems right yeah. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
2007/8/22, Philip Hallstrom <rails-SUcgGwS4C16SUMMaM/qcSw@public.gmane.org>:> > Seems right yeah. >Thank you Philip! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---