Skip to content

Instantly share code, notes, and snippets.

@tubbo
Last active January 4, 2017 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tubbo/c48c39511e2931031e1c3b1a0d9f236b to your computer and use it in GitHub Desktop.
Save tubbo/c48c39511e2931031e1c3b1a0d9f236b to your computer and use it in GitHub Desktop.
class Order < ApplicationRecord
has_many :order_items, dependent: :destroy
def amount
order_items.sum :total_price
end
end
class OrderItem < ApplicationRecord
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment