Skip to content

Commit

Permalink
fix api/reservations#index find statistic_profile_id from the user_id…
Browse files Browse the repository at this point in the history
… because user_id is not a column of reservations table anymore
  • Loading branch information
nflorentin committed Sep 20, 2019
1 parent 22d4d3a commit c49db3b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/controllers/api/reservations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c49db3b

Please sign in to comment.