Sha256: 35c6e649c818de00313b8d0ebde758e5161e86e667037bd9a64d7ae602fb6b37

Contents?: true

Size: 1.1 KB

Versions: 42

Compression:

Stored size: 1.1 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::DebugExceptions::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

42 entries across 42 versions & 3 rubygems

Version Path
railties-5.2.8.1 lib/rails/info_controller.rb
railties-5.2.8 lib/rails/info_controller.rb
railties-5.2.7.1 lib/rails/info_controller.rb
railties-5.2.7 lib/rails/info_controller.rb
railties-5.2.6.3 lib/rails/info_controller.rb
railties-5.2.6.2 lib/rails/info_controller.rb
railties-5.2.6.1 lib/rails/info_controller.rb
railties-5.2.6 lib/rails/info_controller.rb
railties-5.2.4.6 lib/rails/info_controller.rb
railties-5.2.5 lib/rails/info_controller.rb
railties-5.2.4.5 lib/rails/info_controller.rb
railties-5.2.4.4 lib/rails/info_controller.rb
railties-5.2.4.3 lib/rails/info_controller.rb
railties-5.2.4.2 lib/rails/info_controller.rb
railties-5.2.4.1 lib/rails/info_controller.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/railties-5.2.3/lib/rails/info_controller.rb
railties-5.2.4 lib/rails/info_controller.rb
railties-5.2.4.rc1 lib/rails/info_controller.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/railties-5.2.3/lib/rails/info_controller.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/railties-5.2.3/lib/rails/info_controller.rb