Skip to content

Commit

Permalink
Create paginable/research_outputs_controller.rb
Browse files Browse the repository at this point in the history
This commit, along with e289fba are being made to resolve #935.
  • Loading branch information
aaronskiba committed Oct 29, 2024
1 parent e289fba commit 3c5a478
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions app/controllers/paginable/research_outputs_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

module Paginable
# Controller for paginating/sorting/searching the research_outputs table
class ResearchOutputsController < ApplicationController
include Paginable

after_action :verify_authorized

# GET /paginable/plans/:plan_id/research_outputs
def index
@plan = Plan.find_by(id: params[:plan_id])

# Same @research_outputs assignment as app/controllers/research_outputs_controller.rb
@research_outputs = ResearchOutput.includes(:repositories).where(plan_id: @plan.id)
# Same authorize handling as app/controllers/research_outputs_controller.rb
authorize @research_outputs.first || ResearchOutput.new(plan_id: @plan.id)
paginable_renderise(
partial: 'index',
scope: @research_outputs,
query_params: { sort_field: 'research_outputs.title' },
format: :json
)
end
end
end

0 comments on commit 3c5a478

Please sign in to comment.