Sha256: 5a25b172c2a3c586971d148184800ae7befc19044c4f0f816295abdb035688bc

Contents?: true

Size: 1.09 KB

Versions: 25

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require "rails/application_controller"
require "action_dispatch/routing/inspector"

class Rails::InfoController < Rails::ApplicationController # :nodoc:
  prepend_view_path ActionDispatch::DebugView::RESCUES_TEMPLATE_PATH
  layout -> { request.xhr? ? false : "application" }

  before_action :require_local!

  def index
    redirect_to action: :routes
  end

  def properties
    @info = Rails::Info.to_html
    @page_title = "Properties"
  end

  def routes
    if path = params[:path]
      path = URI.parser.escape path
      normalized_path = with_leading_slash path
      render json: {
        exact: match_route { |it| it.match normalized_path },
        fuzzy: match_route { |it| it.spec.to_s.match path }
      }
    else
      @routes_inspector = ActionDispatch::Routing::RoutesInspector.new(_routes.routes)
      @page_title = "Routes"
    end
  end

  private

    def match_route
      _routes.routes.select { |route|
        yield route.path
      }.map { |route| route.path.spec.to_s }
    end

    def with_leading_slash(path)
      ("/" + path).squeeze("/")
    end
end

Version data entries

25 entries across 23 versions & 5 rubygems

Version Path
railties-6.0.2.2 lib/rails/info_controller.rb
argon-1.3.1 vendor/bundle/ruby/2.7.0/gems/railties-6.0.2.1/lib/rails/info_controller.rb
symbolic_enum-1.1.5 vendor/bundle/ruby/2.7.0/gems/railties-6.0.2.1/lib/rails/info_controller.rb
railties-6.0.2.1 lib/rails/info_controller.rb
railties-6.0.2 lib/rails/info_controller.rb
railties-6.0.2.rc2 lib/rails/info_controller.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/railties-6.0.0/lib/rails/info_controller.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/railties-6.0.1/lib/rails/info_controller.rb
railties-6.0.2.rc1 lib/rails/info_controller.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/railties-6.0.0/lib/rails/info_controller.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/railties-6.0.1/lib/rails/info_controller.rb
railties-6.0.1 lib/rails/info_controller.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/railties-6.0.0/lib/rails/info_controller.rb
railties-6.0.1.rc1 lib/rails/info_controller.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/railties-6.0.0/lib/rails/info_controller.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/railties-6.0.0/lib/rails/info_controller.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/railties-6.0.0/lib/rails/info_controller.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/railties-6.0.0/lib/rails/info_controller.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/railties-6.0.0/lib/rails/info_controller.rb
railties-6.0.0 lib/rails/info_controller.rb