File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -47,16 +47,24 @@ def assign_users
4747 raise Pundit ::NotAuthorizedError unless Api ::V0 ::DepartmentsPolicy . new ( @user , @department ) . assign_users?
4848
4949 assign_users_to ( @department . id )
50- redirect_to users_api_v0_departments_path
50+
51+ # Added "status: :see_other" to redirect_to (as we require rediect to be a GET).
52+ # See https://makandracards.com/makandra/38347-redirecting-responses-for-patch-or-delete-will-not-redirect-with-get
53+ redirect_to users_api_v0_departments_path , status : :see_other
5154 end
5255
5356 ##
5457 # Remove departments from the list of users
5558 def unassign_users
56- raise Pudndit ::NotAuthorizedError unless Api ::V0 ::DepartmentsPolicy . new ( @user , @department ) . assign_users?
59+ @department = Department . find ( params [ :id ] )
60+
61+ raise Pundit ::NotAuthorizedError unless Api ::V0 ::DepartmentsPolicy . new ( @user , @department ) . assign_users?
5762
5863 assign_users_to ( nil )
59- redirect_to users_api_v0_departments_path
64+
65+ # Added "status: :see_other" to redirect_to (as we require rediect to be a GET).
66+ # See https://makandracards.com/makandra/38347-redirecting-responses-for-patch-or-delete-will-not-redirect-with-get
67+ redirect_to users_api_v0_departments_path , status : :see_other
6068 end
6169
6270 private
Original file line number Diff line number Diff line change 162162 resources :departments , only : %i[ create index ] do
163163 collection do
164164 get :users
165- patch :unassign_users
166165 end
167166 member do
167+ patch :unassign_users
168168 patch :assign_users
169169 end
170170 end
You can’t perform that action at this time.
0 commit comments