Is there a way to add scope to relationship, so something like this
Serializer:
class CompanySerializer
include FastJsonapi::ObjectSerializer
has_many :employees_temp, scope: ->(record) { record.employees.temp }, serializer: EmployeeSerializer
has_many :employees_full_time, scope: ->(record) { record.employees.full_time }, serializer: EmployeeSerializer
end
Given the following models:
class Company < ApplicationRecord
has_many :employees
end
class Employee < ApplicationRecord
scope :temp, -> { where(type: 'temp') }
scope :full_time, -> { where(type: 'full_time') }
end
Is there a way to add scope to relationship, so something like this
Serializer:
Given the following models: