Sha256: 389801110851ddda447712b81485a640ae49f6d383634e61ed861ec5c76600fe

Contents?: true

Size: 1.08 KB

Versions: 27

Compression:

Stored size: 1.08 KB

Contents

require 'rails/generators'
require "rails/generators/active_record"

# This generator adds a migration for the {FriendlyId::History
# FriendlyId::History} addon.
class FriendlyIdGenerator < ActiveRecord::Generators::Base
  # ActiveRecord::Generators::Base inherits from Rails::Generators::NamedBase which requires a NAME parameter for the
  # new table name. Our generator always uses 'friendly_id_slugs', so we just set a random name here.
  argument :name, type: :string, default: 'random_name'

  class_option :'skip-migration', :type => :boolean, :desc => "Don't generate a migration for the slugs table"
  class_option :'skip-initializer', :type => :boolean, :desc => "Don't generate an initializer"

  source_root File.expand_path('../../friendly_id', __FILE__)

  # Copies the migration template to db/migrate.
  def copy_files
    return if options['skip-migration']
    migration_template 'migration.rb', 'db/migrate/create_friendly_id_slugs.rb'
  end

  def create_initializer
    return if options['skip-initializer']
    copy_file 'initializer.rb', 'config/initializers/friendly_id.rb'
  end
end

Version data entries

27 entries across 27 versions & 3 rubygems

Version Path
friendly_id-5.4.2 lib/generators/friendly_id_generator.rb
friendly_id-5.4.1 lib/generators/friendly_id_generator.rb
friendly_id-5.4.0 lib/generators/friendly_id_generator.rb
friendly_id-5.3.0 lib/generators/friendly_id_generator.rb
friendly_id-5.2.5 lib/generators/friendly_id_generator.rb
friendly_id-5.2.4 lib/generators/friendly_id_generator.rb
friendly_id-5.2.3 lib/generators/friendly_id_generator.rb
friendly_id-5.2.2 lib/generators/friendly_id_generator.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/friendly_id-5.2.1/lib/generators/friendly_id_generator.rb
friendly_id-5.2.1 lib/generators/friendly_id_generator.rb
friendly_id-5.2.0 lib/generators/friendly_id_generator.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/friendly_id-5.0.5/lib/generators/friendly_id_generator.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/friendly_id-5.0.5/lib/generators/friendly_id_generator.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/friendly_id-5.0.5/lib/generators/friendly_id_generator.rb
friendly_id-5.2.0.beta.1 lib/generators/friendly_id_generator.rb
friendly_id-5.0.5 lib/generators/friendly_id_generator.rb
friendly_id-5.1.0 lib/generators/friendly_id_generator.rb
friendly_id-5.1.0.beta.1 lib/generators/friendly_id_generator.rb
friendly_id-5.0.4 lib/generators/friendly_id_generator.rb
friendly_id-5.0.3 lib/generators/friendly_id_generator.rb