scinote-web/app/controllers/api/v1/protocols_controller.rb

30 lines
866 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module Api
module V1
class ProtocolsController < BaseController
2020-08-07 22:51:57 +08:00
include Api::V1::ExtraParams
before_action :load_team, :load_project, :load_experiment, :load_task
before_action only: :show do
load_protocol(:id)
end
def index
protocols = @task.protocols
.page(params.dig(:page, :number))
.per(params.dig(:page, :size))
render jsonapi: protocols,
2020-08-07 22:51:57 +08:00
each_serializer: ProtocolSerializer, rte_rendering: render_rte?, team: @team
end
2020-08-07 22:51:57 +08:00
def show
render jsonapi: @protocol, serializer: ProtocolSerializer,
include: include_params,
rte_rendering: render_rte?,
team: @team
end
end
end
end