-
Notifications
You must be signed in to change notification settings - Fork 425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relationship scope #448
Comments
It seems Netflix has abandoned this project. The community created a new
fork to continue supporting this project. Please refer
https://github.com/fast-jsonapi/fast_jsonapi
…On Wed, 6 Nov, 2019, 12:42 PM Kapil, ***@***.***> wrote:
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: EmployeeSerializerend
Given the following models:
class Company < ApplicationRecord
has_many :employeesend
class Employee < ApplicationRecord
scope :temp, -> { where(type: 'temp') }
scope :full_time, -> { where(type: 'full_time') }end
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#448?email_source=notifications&email_token=ACEAHZM3ZUIG7LPQ7CTGZUTQSJU4HA5CNFSM4JJQVLXKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HXEMOGQ>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACEAHZJAKXZUDZGZLY7VMLTQSJU4HANCNFSM4JJQVLXA>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there a way to add scope to relationship, so something like this
Serializer:
Given the following models:
The text was updated successfully, but these errors were encountered: