Update payments_controller.rb

This commit is contained in:
2016-08-05 21:08:05 -04:00
committed by GitHub
parent f6f1ca4c04
commit 5a91e21d45

View File

@@ -27,13 +27,14 @@ class PaymentsController < ApplicationController
end
def create
@customer = Customer.find_by_id(params[:customer_id])
if @customer
# TODO things
@payment = Payment.new(params[:payment])
if @payment.save
flash[:notice] = "Payment Saved"
redirect_to Customer.find_by_id(@payment.customer_id)
else
flash[:error] = @customer.errors.full_messages.to_sentence
redirect_to new_payment_path
end
flash[:error] = @payment.errors.full_messages.to_sentence
redirect_to new_customer_path
end
end
private