From 5a19d47376d1241245a84ad609aa7f450038a855 Mon Sep 17 00:00:00 2001 From: Rishabh Saxena Date: Thu, 10 Mar 2016 03:20:15 +0530 Subject: [PATCH] checking if no tickets are purchased. passing tests. --- app/controllers/conference_registrations_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/conference_registrations_controller.rb b/app/controllers/conference_registrations_controller.rb index d7d111ca..34a1effd 100644 --- a/app/controllers/conference_registrations_controller.rb +++ b/app/controllers/conference_registrations_controller.rb @@ -87,7 +87,9 @@ class ConferenceRegistrationsController < ApplicationController def destroy tickets_purchased = TicketPurchase.find_by(conference_id: @registration.conference_id) if @registration.destroy - tickets_purchased.destroy + if tickets_purchased + tickets_purchased.destroy + end redirect_to root_path, notice: "You are not registered for #{@conference.title} anymore!" else