Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save josecoelho/1ca7a3fe68599898cb43 to your computer and use it in GitHub Desktop.
Save josecoelho/1ca7a3fe68599898cb43 to your computer and use it in GitHub Desktop.
def create_invoices
interval = 1.month
cicle = 12 #quantidade desejada
start_date = Date.today #data inicial
current_date = start_date
cicle.times do
# criar o que você precisa, alguns exemplos:
# invoices.create(date: current_date, outro_campo: "Algum outro valor")
# invoices << Invoice.create(date: current_date)
# Invoice.create(date: current_date, relation_id: self.id)
# imprindo data atual para fins de demonstração
puts current_date
current_date += interval
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment