Created
May 28, 2019 16:00
-
-
Save talum/540feec39401a1fc584094d2b97e5179 to your computer and use it in GitHub Desktop.
Invoices Controller 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class InvoicesController < ApplicationController | |
def update | |
# The developer reasons that adding a timestamp to the params to | |
# leverage the existing code will do the trick | |
if params[:cancel] | |
invoice_params[:closed_at] = Time.current | |
end | |
invoice = Invoice.find(params[:id]) | |
invoice.update!(invoice_params) # what's in these params?!? | |
redirect_to invoice | |
end | |
private | |
def invoice_params | |
params.require(:invoice).permit(:amount_due, :closed_at, :due_date, | |
:scheduled_send_date, :paid_at) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment