1 2 3 4 5 6 7 8 9 10 11 12 13
class WholesaleProduct < ActiveRecord::Base after_initialize :set_prices def set_prices if msrp.nil? && !wholesale.nil? self.msrp = 2 * wholesale elsif !msrp.nil? && wholesale.nil? self.wholesale = msrp / 2 end end end