1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# frozen_string_literal: true # ProductOrder # quantity: integer class ProductOrder < ApplicationRecord belongs_to :order belongs_to :product def total if quantity < 5 product.unitary_price * quantity else product.bulk_price * quantity end end end