2012-07-02 03:00:10 +00:00
|
|
|
require 'action_dispatch/routing/inspector'
|
2012-05-22 23:23:17 +00:00
|
|
|
|
2012-12-11 00:15:30 +00:00
|
|
|
class Rails::InfoController < ActionController::Base # :nodoc:
|
2012-12-10 01:51:58 +00:00
|
|
|
self.view_paths = File.expand_path('../templates', __FILE__)
|
2012-12-17 20:26:46 +00:00
|
|
|
prepend_view_path ActionDispatch::DebugExceptions::RESCUES_TEMPLATE_PATH
|
2013-01-04 07:02:01 +00:00
|
|
|
layout -> { request.xhr? ? nil : 'application' }
|
2012-05-22 23:23:17 +00:00
|
|
|
|
|
|
|
before_filter :require_local!
|
|
|
|
|
|
|
|
def index
|
|
|
|
redirect_to '/rails/info/routes'
|
|
|
|
end
|
|
|
|
|
2006-03-29 15:11:47 +00:00
|
|
|
def properties
|
2012-05-22 23:23:17 +00:00
|
|
|
@info = Rails::Info.to_html
|
|
|
|
end
|
|
|
|
|
|
|
|
def routes
|
2012-12-15 17:36:26 +00:00
|
|
|
@routes = ActionDispatch::Routing::RoutesInspector.new.collect_routes(_routes.routes)
|
2006-03-19 18:45:26 +00:00
|
|
|
end
|
2010-02-01 10:40:27 +00:00
|
|
|
|
|
|
|
protected
|
|
|
|
|
2012-05-22 23:23:17 +00:00
|
|
|
def require_local!
|
|
|
|
unless local_request?
|
2012-10-14 10:03:39 +00:00
|
|
|
render text: '<p>For security purposes, this information is only available to local requests.</p>', status: :forbidden
|
2012-05-22 23:23:17 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def local_request?
|
|
|
|
Rails.application.config.consider_all_requests_local || request.local?
|
2010-02-01 10:40:27 +00:00
|
|
|
end
|
2006-03-29 15:11:47 +00:00
|
|
|
end
|