# frozen_string_literal: true

require 'rails'
require 'erd/engine'

module Erd
  autoload :Migrator, 'erd/migrator'
  autoload :GenaratorRunner, 'erd/generator_runner'

  class Railtie < ::Rails::Railtie #:nodoc:
    initializer 'erd' do
      ActiveSupport.on_load(:after_initialize) do
        if Rails.env.development?
          Rails.application.routes.append do
            mount Erd::Engine, :at => '/erd'
          end
        end
      end
    end
  end
end

# frozen_string_literal: true

require 'rails'
require 'erd/engine'

module Erd
  autoload :Migrator, 'erd/migrator'
  autoload :GenaratorRunner, 'erd/generator_runner'

  class Railtie < ::Rails::Railtie #:nodoc:
    initializer 'erd' do
      ActiveSupport.on_load(:after_initialize) do
        if Rails.env.development?
          Rails.application.routes.prepend do
            mount Erd::Engine, :at => '/erd'
          end
        end
      end
    end
  end
end

Prepend the root route instead of appending it
Prepend the root route instead of appending it

By prepending the /erd route instead of appending it we can simply give this route the highest priority.
That way it won't get overridden by other, more generic route definitions.

fix #25