Skip to content

Instantly share code, notes, and snippets.

@crispincornett
Created October 5, 2012 20:39
Show Gist options
  • Save crispincornett/3842246 to your computer and use it in GitHub Desktop.
Save crispincornett/3842246 to your computer and use it in GitHub Desktop.
Invoice Transaction
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