class BinaryPoint < ActiveRecord::Base belongs_to :customer belongs_to :order scope :left, lambda { where(:side => 1) } scope :right, lambda { where(:side => 2) } after_save do if self.side == 1 self.customer.update_left_binary_points else self.customer.update_right_binary_points end end end