Sha256: 101bebb895f282d77bc96f2d2b47996ffcf5e92d083d26d550ad81ba869fdfc7
Contents?: true
Size: 853 Bytes
Versions: 7
Compression:
Stored size: 853 Bytes
Contents
require "rails/generators" # Add statesman attributes to a pre-existing transition class module Statesman class MigrationGenerator < Rails::Generators::Base desc "Add the required Statesman attributes to your transition model" argument :parent, type: :string, desc: "Your parent model name" argument :klass, type: :string, desc: "Your transition model name" source_root File.expand_path('../templates', __FILE__) def create_model_file template("update_migration.rb.erb", file_name) end private def next_migration_number Time.now.utc.strftime("%Y%m%d%H%M%S") end def file_name "db/migrate/#{next_migration_number}_add_statesman_to_#{table_name}.rb" end def table_name klass.underscore.pluralize end def parent_id parent.underscore + "_id" end end end
Version data entries
7 entries across 7 versions & 1 rubygems