Module: Grape::Helpers::ActiveModelSerializers

Defined in:
lib/grape/helpers/active_model_serializers.rb

Instance Method Summary collapse

Instance Method Details

#render(resource, active_model_serializer_options = {}) ⇒ Object

A convenience method for passing ActiveModelSerializers serializer options

Example: To include relationships in the response: render(post, include: ['comments'])

Example: To include pagination meta data: render(posts, meta: { page: posts.page, total_pages: posts.total_pages })


11
12
13
14
# File 'lib/grape/helpers/active_model_serializers.rb', line 11

def render(resource, active_model_serializer_options = {})
  env[:active_model_serializer_options] = active_model_serializer_options
  resource
end