Sha256: d2ce50ec6baf676892ffe5338d755810f56f1765d6b7348f396fd68471680a52

Contents?: true

Size: 648 Bytes

Versions: 10

Compression:

Stored size: 648 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',
        %(\n  mount Guts::Engine => "#{options[:pathname]}"\n),
        after: '.routes.draw do'
      )
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
guts-3.1.2 lib/generators/guts/routes/routes_generator.rb
guts-3.1.1 lib/generators/guts/routes/routes_generator.rb
guts-3.1.0 lib/generators/guts/routes/routes_generator.rb
guts-3.0.1 lib/generators/guts/routes/routes_generator.rb
guts-3.0.0 lib/generators/guts/routes/routes_generator.rb
guts-2.1.0 lib/generators/guts/routes/routes_generator.rb
guts-2.0.2 lib/generators/guts/routes/routes_generator.rb
guts-2.0.1 lib/generators/guts/routes/routes_generator.rb
guts-2.0.0 lib/generators/guts/routes/routes_generator.rb
guts-1.4.0 lib/generators/guts/routes/routes_generator.rb