aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/invoice.rb
blob: df37e2a9e15494b9ffd0c3ed1918d9458db50fff (plain) (blame)
1
2
3
4
5
# frozen_string_literal: true
class Invoice < ActiveRecord::Base
  has_many :line_items, autosave: true
  before_save { |record| record.balance = record.line_items.map(&:amount).sum }
end