Skip to content

Commit

Permalink
quick reservation, check if users tenant is nil; rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
Nils Bartels committed Dec 20, 2023
1 parent 22bcdf4 commit e517f41
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def update
render :edit
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_profile
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/reservations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ def create

# quick reservation
if patched_params["desk_id"].nil?
if current_user.tenant.nil?
redirect_to root_path, alert: "Cannot create a quick reservation without configured user tenant. Please configure tenant in your profile."
return
end

# the .to_a is important, as we do not want to call .delete on the collection of Desks
available_desks = Desk.includes(room: { floor: { location: :tenant } }).all.order("RANDOM()").load_async.to_a
available_desks.delete_if { |desk| desk.room.floor.location.tenant.id != current_user.tenant.id }
Expand Down

0 comments on commit e517f41

Please sign in to comment.