Added check for conference end_date in payments#new

This commit is contained in:
rishabhptr 2017-10-10 21:51:24 +05:30
parent 78eb58c93e
commit 9171beabf8

View file

@ -10,6 +10,9 @@ class PaymentsController < ApplicationController
def new
@total_amount_to_pay = Ticket.total_price(@conference, current_user, paid: false)
if @conference.end_date < Date.today
raise CanCan::AccessDenied.new("This conference has ended on #{@conference.end_date}!", :new, Payment)
end
if @total_amount_to_pay.zero?
raise CanCan::AccessDenied.new('Nothing to pay for!', :new, Payment)
end