Last active
October 29, 2017 17:03
-
-
Save StaverDmitry/27466a27dfa6d94fa8600f88ec2cc189 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update | |
respond_to do |format| | |
if @enquiry.update(enquiry_params) | |
cust = @enquiry.customer | |
cust.title=params[:enquiry][:customer][:title] if params[:enquiry][:customer][:title].present? | |
cust.first_name=params[:enquiry][:customer][:first_name] if params[:enquiry][:customer][:first_name].present? | |
cust.last_name=params[:enquiry][:customer][:last_name] if params[:enquiry][:customer][:last_name].present? | |
cust.address=params[:enquiry][:customer][:address] if params[:enquiry][:customer][:address].present? | |
cust.age=params[:enquiry][:customer][:age] if params[:enquiry][:customer][:age].present? | |
cust.nationality=params[:enquiry][:customer][:nationality] if params[:enquiry][:customer][:nationality].present? | |
cust.latitude=params[:enquiry][:customer][:latitude] if params[:enquiry][:customer][:latitude].present? | |
cust.longitude=params[:enquiry][:customer][:longitude] if params[:enquiry][:customer][:longitude].present? | |
cust.country_code=params[:enquiry][:customer][:country_code] if params[:enquiry][:customer][:country_code].present? | |
cust.tel=params[:enquiry][:customer][:tel] if params[:enquiry][:customer][:tel].present? | |
cust.save | |
format.html { redirect_to booking_path(@enquiry), notice: 'Enquiry was successfully updated.' } | |
format.json { render :show, status: :ok, location: @enquiry } | |
else | |
format.html { render :edit } | |
format.json { render json: @enquiry.errors, status: :unprocessable_entity } | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment