aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/invoice.rb
blob: 1851792ed5b44381dfa294abf49e0c878bdcbbe9 (plain) (blame)
1
2
3
4
5
6
# 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