Module: Jsonapi::QueryBuilder::Mixins::Include

Included in:
BaseQuery
Defined in:
lib/jsonapi/query_builder/mixins/include.rb

Instance Method Summary collapse

Instance Method Details

#add_includes(collection, include_params = send(:include_params)) ⇒ ActiveRecord::Relation

Eager loads the relationships that will be included in the response, based on the Json:Api include query parameter.

Parameters:

  • collection (ActiveRecord::Relation)
  • include_params (Object) (defaults to: send(:include_params))

    Optional explicit include params

Returns:

  • (ActiveRecord::Relation)

    Collection with eager loaded included relations



12
13
14
# File 'lib/jsonapi/query_builder/mixins/include.rb', line 12

def add_includes(collection, include_params = send(:include_params))
  collection.includes(formatted_include_params(include_params))
end