From f8835c49d0b59f18ceddd7bec180848ccb226b82 Mon Sep 17 00:00:00 2001 From: bohung Date: Thu, 4 Aug 2022 16:00:20 +0800 Subject: [PATCH] Fix bug. --- app/controllers/property_hires_controller.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/controllers/property_hires_controller.rb b/app/controllers/property_hires_controller.rb index 013d3ab..4a91ffc 100644 --- a/app/controllers/property_hires_controller.rb +++ b/app/controllers/property_hires_controller.rb @@ -217,8 +217,9 @@ class PropertyHiresController < ApplicationController end end end + phire_id = params[:phire_id] || params[:p_hire][:id] if params[:url] == "admin" - params[:phire_id] = booking_p[:id] + phire_id = booking_p[:id] end data = check_for_availability(start_time,end_time,booking_p[:property_id], booking_p[:recurring_interval], booking_p[:recurring_end_date], time_setting_id) if data["success"] == true @@ -230,9 +231,13 @@ class PropertyHiresController < ApplicationController end if data["success"] == true hire = nil - if params[:phire_id] - hire = PHire.find(params[:phire_id]) - hire.update_attributes(booking_p) + if phire_id + hire = PHire.find(phire_id) rescue nil + if hire.nil? + hire = PHire.new(booking_p) + else + hire.update_attributes(booking_p) + end else hire = PHire.new(booking_p) end