diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/order.rb | 10 | ||||
-rw-r--r-- | app/models/payment.rb | 8 | ||||
-rw-r--r-- | app/models/product.rb | 2 | ||||
-rw-r--r-- | app/models/product_order.rb | 8 |
4 files changed, 28 insertions, 0 deletions
diff --git a/app/models/order.rb b/app/models/order.rb new file mode 100644 index 0000000..ae5a0d5 --- /dev/null +++ b/app/models/order.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +# Order +# public_id: string +class Order < ApplicationRecord + belongs_to :user_account + has_one :payment + has_many :product_orders + has_many :products, through: :product_orders +end diff --git a/app/models/payment.rb b/app/models/payment.rb new file mode 100644 index 0000000..5d5e862 --- /dev/null +++ b/app/models/payment.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +# Payment +# total: float +class Payment < ApplicationRecord + has_one :order + belongs_to :card +end diff --git a/app/models/product.rb b/app/models/product.rb index c4514a2..51d6c57 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -14,6 +14,8 @@ class Product < ApplicationRecord has_many :product_reviews has_many :product_carts has_many :carts, through: :product_carts + has_many :product_orders + has_many :orders, through: :product_orders validates :name, presence: true validates :unitary_price, presence: true diff --git a/app/models/product_order.rb b/app/models/product_order.rb new file mode 100644 index 0000000..004f8fc --- /dev/null +++ b/app/models/product_order.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +# ProductOrder +# quantity: integer +class ProductOrder < ApplicationRecord + belongs_to :order + belongs_to :product +end |