Jsonapi serializer parameters to has_many query

812 views Asked by At

I would need to filter the records to include for has_many relation with the params that are passed to the serializer. The object_method_name option is invoking a method in the model, but how can I pass the params to the method?

Or is there a way to use a Proc for getting the records for has_many relation? Couldn't find any documentation for that at least.

1

There are 1 answers

0
Mika On

Found it. You can give a block to it

has_many :records do |object, params|
  object.my_records(params)
end