Sha256: 9ad4dfb596ab01e96650936d89c840d692218f9e10c374bee9df727bb7e6451c
Contents?: true
Size: 702 Bytes
Versions: 8
Compression:
Stored size: 702 Bytes
Contents
require 'rails/generators/base' require 'rails/generators/active_record' class SlugMigrationGenerator < Rails::Generators::Base include ActiveRecord::Generators::Migration source_root File.expand_path('../templates', __FILE__) argument :slugged_model, type: :string, required: true class_option :slug_name, type: :string, default: 'slug' def create_migration_file migration_template "slug_migration.rb", "db/migrate/add_slug_to_#{slugged_model_table}.rb" end private def slugged_model_table slugged_model.underscore.pluralize end def slugged_model_class_name slugged_model.camelcase end def slug_column_name options.fetch("slug_name").underscore end end
Version data entries
8 entries across 8 versions & 1 rubygems