Sha256: 09b155ae266290aaf5f08e8cc75d89f539d419df7bf65b0fc00f008b532531e9

Contents?: true

Size: 649 Bytes

Versions: 7

Compression:

Stored size: 649 Bytes

Contents

module Guts
  # Routes generator
  class RoutesGenerator < Rails::Generators::Base
    # Optional pathname to use for the mount route
    class_option :pathname,
                 desc: 'The path name for the admin panel',
                 type: 'string',
                 default: '/admin',
                 required: false

    # Inserts the route into an existing routes file
    def add_route
      options[:pathname].insert(0, '/') unless options[:pathname][0] == '/'

      inject_into_file(
        'config/routes.rb',
        %Q(\n  mount Guts::Engine => "#{options[:pathname]}"\n),
        after: '.routes.draw do'
      )
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
guts-1.3.6 lib/generators/guts/routes/routes_generator.rb
guts-1.3.5 lib/generators/guts/routes/routes_generator.rb
guts-1.3.4 lib/generators/guts/routes/routes_generator.rb
guts-1.3.3 lib/generators/guts/routes/routes_generator.rb
guts-1.3.2 lib/generators/guts/routes/routes_generator.rb
guts-1.3.1 lib/generators/guts/routes/routes_generator.rb
guts-1.3.0 lib/generators/guts/routes/routes_generator.rb