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