33module BetterTogether
44 class PeopleController < FriendlyResourceController # rubocop:todo Style/Documentation
55 before_action :set_person , only : %i[ show edit update destroy ]
6- before_action :authorize_person , only : %i[ show edit update destroy ]
7- after_action :verify_authorized , except : :index
86
97 # GET /people
108 def index
11- authorize resource_class
12- @people = policy_scope ( resource_class . with_translations )
9+ @people = resource_collection
1310 end
1411
1512 # GET /people/1
@@ -57,12 +54,7 @@ def destroy
5754 redirect_to people_url , notice : 'Person was successfully deleted.' , status : :see_other
5855 end
5956
60- private
61-
62- # Adds a policy check for the person
63- def authorize_person
64- authorize @person
65- end
57+ protected
6658
6759 def id_param
6860 params [ :id ] || params [ :person_id ]
@@ -97,7 +89,7 @@ def resource_class
9789 end
9890
9991 def resource_collection # rubocop:todo Metrics/MethodLength
100- resource_class . with_translations . with_attached_profile_image . with_attached_cover_image . includes (
92+ policy_scope ( resource_class . with_translations . with_attached_profile_image . with_attached_cover_image . includes (
10193 contact_detail : %i[ phone_numbers email_addresses website_links addresses social_media_accounts ] ,
10294 person_platform_memberships : {
10395 joinable : [ :string_translations , { profile_image_attachment : :blob } ] ,
@@ -107,7 +99,7 @@ def resource_collection # rubocop:todo Metrics/MethodLength
10799 joinable : [ :string_translations , { profile_image_attachment : :blob } ] ,
108100 role : [ :string_translations ]
109101 }
110- )
102+ ) )
111103 end
112104 end
113105end
0 commit comments