module Baclight class Employer < BaclightRecord self.table_name = 'Employers' has_one :baclight_carrier, through: :baclight_broker belongs_to :baclight_broker, class_name: "Baclight::Broker", foreign_key: "broker_id" has_many :baclight_members, class_name: "Baclight::Member", foreign_key: "employer_id", primary_key: "id" # alias_attribute :id, :id # alias_attribute :name, :name # alias_attribute :slug, :slug # alias_attribute :pl_plan_key, :pl_plan_key # alias_attribute :company_pb_entity_key, :company_pb_entity_key # alias_attribute :plan_id, :plan_id # alias_attribute :group_number, :group_number # alias_attribute :effective_date, :effective_date # alias_attribute :active, :active # alias_attribute :initialized, :initialized # alias_attribute :broker_id, :broker_id # alias_attribute :created_at, :created_at # alias_attribute :updated_at, :updated_at def carrier_id self.baclight_broker.carrier_id end def belongs_to_levels self.joins(baclight_broker: :baclight_carrier).select( 'baclight_broker.id AS broker_id', 'baclight_carrier.id AS carrier_id' ) end end end