Hi!
I have a uncommon (I think problem). In my RoR app there’re 3 models:
- Transaction (date:datetime, worker_id:integer, successful:boolean)
- Sale (amount:integer, transaction_id:integer, medicine_id:integer)
- Medicine (…)
Transaction is some kind of bill, is like container of Sales with one
attached Medicine, so it looks like that:
Transaction —[0…*]—> Sale —[1…1]—> Medicine
or like a tree:
Transaction
-> Sale -> Medicine
-> Sale -> Medicine
How to make relations? I tried to use these ones:
Transaction:
has_many :sales
Sale:
belongs_to :transactions
has_one :medicine
So now the problems starts, because even if I create new transaction
and then try to make sale, nothing happens It says “Successfuly
created new sale”, but it doesn’t show on listing.
Could anyone explain how to connect these models through relations?