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

34 lines
802 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module Api
module V1
class ReportsController < BaseController
before_action :load_team
before_action :load_project
before_action :load_report, only: :show
def index
reports = @project.reports
.page(params.dig(:page, :number))
.per(params.dig(:page, :size))
render jsonapi: reports,
each_serializer: ReportSerializer,
hide_project: true
end
def show
render jsonapi: @report,
serializer: ReportSerializer,
hide_project: true,
include: :user
end
private
def load_report
@report = @project.reports.find(params.require(:id))
end
end
end
end