I used to work on an online purchasing system. What you want to do is the Order class and the LineItem class. LineItems stores product data, such as price, quantity, and possibly some other information needed for recording. This is harder, but this is the only way to find out the details.
An order simply consists of LineItems and probably contains the shipping and billing addresses. The total value of the order can be calculated by adding LineItems.
Basically, you freeze data before a person makes a purchase. When they are added to the order, the data is frozen because LineItems duplicates nessacary information. That way, when a product is removed from your system, you can still understand old orders.
, rails "AASM" (, ), .
: AASM http://github.com/rubyist/aasm/tree/master