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