improve flash error collection

improve views
This commit is contained in:
Rishabh Saxena 2016-08-11 17:47:52 +05:30
parent 6bd2e5e335
commit 261d7dd0de
4 changed files with 15 additions and 19 deletions

View file

@ -23,6 +23,7 @@ class PaymentsController < ApplicationController
else
@total_amount_to_pay = Ticket.total_price(@conference, current_user, paid: false)
@unpaid_ticket_purchases = current_user.ticket_purchases.unpaid.by_conference(@conference)
flash[:error] = @payment.errors.full_messages.to_sentence + ' Please try again with correct credentials.'
render :new
end
end

View file

@ -4,7 +4,7 @@ class TicketPurchasesController < ApplicationController
authorize_resource :conference_registrations, class: Registration
def create
TicketPurchase.by_conference(@conference).unpaid.by_user(current_user).destroy_all
current_user.ticket_purchases.by_conference(@conference).unpaid.destroy_all
message = TicketPurchase.purchase(@conference, current_user, params[:tickets][0])
if message.blank?
if current_user.ticket_purchases.by_conference(@conference).unpaid.any?