Open
Description
Using JSONAPI, I never want to load relationships
unless they are also include
'd. By default:
class PostSerializer < ActiveModel::Serializer
has_many :comments
end
Does nothing for me but cause an unnecessary DB hit. Instead, by desired behavior would be:
class PostSerializer < ActiveModel::Serializer
has_many :comments, if: :comments_included?
def comments_included?
self.instance_options[:include].include?(:comments)
end
end
Unfortunately the include
option is passed to the adapter, but unavailable on the serializer.
Can we add include
to the options passed to the serializer?