From 2247231d6eb6a74c9a4f62738d3a3b69bdf0662f Mon Sep 17 00:00:00 2001 From: rishabhptr Date: Mon, 25 Sep 2017 21:30:46 +0530 Subject: [PATCH] Added amount check for payments#new --- app/controllers/payments_controller.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/controllers/payments_controller.rb b/app/controllers/payments_controller.rb index b5e2c193..bee58f6c 100644 --- a/app/controllers/payments_controller.rb +++ b/app/controllers/payments_controller.rb @@ -3,6 +3,7 @@ class PaymentsController < ApplicationController load_and_authorize_resource load_resource :conference, find_by: :short_title authorize_resource :conference_registrations, class: Registration + before_action :check_amount, only: [:new] def index @payments = current_user.payments @@ -28,6 +29,11 @@ class PaymentsController < ApplicationController end end + def check_amount + @total_amount_to_pay = Ticket.total_price(@conference, current_user, paid: false) + redirect_to root_path if @total_amount_to_pay.zero? + end + private def payment_params