Fix authorization for communitySolutionsIndex

This commit is contained in:
Sebastian Serth
2022-08-18 16:28:10 +02:00
parent 7da47a7b5c
commit 3248bd74d1
2 changed files with 14 additions and 17 deletions

View File

@ -11,7 +11,7 @@ class CommunitySolutionsController < ApplicationController
# GET /community_solutions
def index
@community_solutions = CommunitySolution.all
@community_solutions = CommunitySolution.all.paginate(page: params[:page], per_page: per_page_param)
authorize!
end
@ -85,7 +85,7 @@ class CommunitySolutionsController < ApplicationController
private
def authorize!
authorize(@community_solution)
authorize(@community_solution || @community_solutions)
end
# Use callbacks to share common setup or constraints between actions.

View File

@ -1,19 +1,16 @@
h1 Listing community_solutions
h1 = t('activerecord.models.community_solution.other')
table
thead
tr
th
th
th
tbody
- @community_solutions.each do |community_solution|
.table-responsive
table.table.mt-4
thead
tr
td = link_to 'Show', community_solution
td = link_to 'Edit', edit_community_solution_path(community_solution)
td = link_to 'Destroy', community_solution, data: { confirm: 'Are you sure?' }, method: :delete
th = t('activerecord.attributes.exercise.title')
th colspan=1 = t('shared.actions')
br
tbody
- @community_solutions.each do |community_solution|
tr
td = community_solution.exercise.title
td = link_to 'Edit', edit_community_solution_path(community_solution)
= link_to 'New Community solution', new_community_solution_path
= render('shared/pagination', collection: @community_solutions)