Sha256: d09b457ea35fe006639a7a66d0b1c146538208731e2ebb7f15eafa942c83b8a9
Contents?: true
Size: 1.31 KB
Versions: 17
Compression:
Stored size: 1.31 KB
Contents
require "rails/generators" require "rails/generators/migration" # rails g payday:setup <invoice_name> <line_item_name> # Generates models for invoicing with Payday includes prepped # Params: # OPTIONS: # --skip-migration - Does not create the migration file for invoicing module Payday class SetupGenerator < Rails::Generators::Base include Rails::Generators::Migration source_root File.expand_path("../templates", __FILE__) class_option :invoice_name, type: :string, default: "Invoice" class_option :line_item_name, type: :string, default: "LineItem" class_option :skip_migration, desc: "Does not create the migration file for tables", type: :boolean def generate_invoice_model template "invoice.rb", "app/models/#{options.invoice_name.underscore}.rb" end def generate_line_item_model template "line_item.rb", "app/models/#{options.line_item_name.underscore}.rb" end def generate_migration unless options.skip_migration? migration_template "migration.rb", "db/migrate/create_payday_tables.rb" end end private def self.next_migration_number(dirname) if ActiveRecord::Base.timestamped_migrations Time.now.utc.strftime("%Y%m%d%H%M%S") else "%.3d" % (current_migration_number(dirname) + 1) end end end end
Version data entries
17 entries across 17 versions & 2 rubygems