From c49db3b5126cc1ffdfbac6b80ae1686f0bb9e2ed Mon Sep 17 00:00:00 2001 From: Nicolas Florentin Date: Fri, 20 Sep 2019 15:23:53 +0200 Subject: [PATCH] fix api/reservations#index find statistic_profile_id from the user_id because user_id is not a column of reservations table anymore --- app/controllers/api/reservations_controller.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/reservations_controller.rb b/app/controllers/api/reservations_controller.rb index 244a91ff51..333dc3534e 100644 --- a/app/controllers/api/reservations_controller.rb +++ b/app/controllers/api/reservations_controller.rb @@ -11,7 +11,10 @@ def index if params[:reservable_id] && params[:reservable_type] && params[:user_id] params[:user_id] = current_user.id unless current_user.admin? - @reservations = Reservation.where(params.permit(:reservable_id, :reservable_type, :user_id)) + where_clause = params.permit(:reservable_id, :reservable_type).to_h + where_clause[:statistic_profile_id] = StatisticProfile.find_by!(user_id: params[:user_id]) + + @reservations = Reservation.where(where_clause) elsif params[:reservable_id] && params[:reservable_type] && current_user.admin? @reservations = Reservation.where(params.permit(:reservable_id, :reservable_type)) else