I have the following method in an API controller:
module Api
module V1
class ArticlesController < Api::BaseController
def show
article = Article.find(params[:id])
render json: article
end
end end end
And while using the active_model_serializers
gem, I have the following serializer:
class Api::V1::ArticleSerializer < ActiveModel::Serializer
attributes :id, :author_id, :title, :description
end
For all API requests the server should include information about the session, such as the api token and the current user. So in the above case the generated json shouldn't only include the attributes mentioned in the articles serializer but also for example the api token.
Where and how does one normally include this session information to send to the API front end? Is this perhaps in a separate serializer that is included in addition to in this case the articles serializer?