This commit is contained in:
Rishabh Singh 2017-12-13 09:24:47 +00:00 • committed by GitHub
commit 225d82a6b7
2 changed files with 7 additions and 1 deletions

View file

@ -1,6 +1,6 @@
class PaymentsController < ApplicationController
before_action :authenticate_user!
load_and_authorize_resource
load_and_authorize_resource except: :new
load_resource :conference, find_by: :short_title
authorize_resource :conference_registrations, class: Registration
@ -9,6 +9,7 @@ class PaymentsController < ApplicationController
end
def new
authorize! :new, Payment.new(conference_id: @conference.id)
@total_amount_to_pay = Ticket.total_price(@conference, current_user, paid: false)
if @total_amount_to_pay.zero?
raise CanCan::AccessDenied.new('Nothing to pay for!', :new, Payment)

View file

@ -73,6 +73,11 @@ class Ability
can :index, Ticket
can :manage, TicketPurchase, user_id: user.id
can [:new, :create], Payment, user_id: user.id
can :new, Payment do |payment|
payment.conference.end_date >= Date.today
end
can [:index, :show], PhysicalTicket, user: user
can [:new, :create], Booth do |booth|