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
Pragmatic Bookshelf: By Developers, For Developers).
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