1 2 3 4 5 6 7 8 9 10 11 12 13 14
class CustomerCarrier < ActiveRecord::Base cattr_accessor :current_customer belongs_to :customer belongs_to :carrier default_scope -> { if current_customer where(customer: current_customer) else all end } end