From 9171beabf8b99bb5ab8eaff636f0bb3bc259763b Mon Sep 17 00:00:00 2001 From: rishabhptr Date: Tue, 10 Oct 2017 21:51:24 +0530 Subject: [PATCH] Added check for conference end_date in payments#new --- app/controllers/payments_controller.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/payments_controller.rb b/app/controllers/payments_controller.rb index 322ed397..ae8c89da 100644 --- a/app/controllers/payments_controller.rb +++ b/app/controllers/payments_controller.rb @@ -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