Created
October 5, 2012 20:39
-
-
Save crispincornett/3842246 to your computer and use it in GitHub Desktop.
Invoice Transaction
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 generate | |
@accounts = Account.all | |
@invoices = [] | |
@accounts.each do |a| | |
inv = Invoice.generate_account_billing(a, params[:invoice]) | |
@invoices << inv | |
end | |
Invoice.transaction do | |
@invoices.each do |i| | |
i.save | |
end | |
redirect_to invoices_url, notice: "Invoices have been successfully generated." | |
end # End Transaction | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment