From 5a91e21d4557953fb67ce43bd850514489d1602b Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Fri, 5 Aug 2016 21:08:05 -0400 Subject: [PATCH] Update payments_controller.rb --- app/controllers/payments_controller.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/controllers/payments_controller.rb b/app/controllers/payments_controller.rb index b13ce49..2f19d0f 100644 --- a/app/controllers/payments_controller.rb +++ b/app/controllers/payments_controller.rb @@ -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