Added amount check for payments#new

This commit is contained in:
rishabhptr 2017-09-25 21:30:46 +05:30 committed by Stella Rouzi
parent 7e9d1dbf84
commit 2247231d6e

View file

@ -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