2012-07-01 23:00:10 -04:00
|
|
|
require 'action_dispatch/routing/inspector'
|
2012-05-22 19:23:17 -04:00
|
|
|
|
2006-03-29 10:11:47 -05:00
|
|
|
class Rails::InfoController < ActionController::Base
|
2012-05-22 19:23:17 -04:00
|
|
|
self.view_paths = File.join(File.dirname(__FILE__), 'templates')
|
|
|
|
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-07-08 12:25:45 -04:00
|
|
|
inspector = ActionDispatch::Routing::RoutesInspector.new
|
2012-05-22 19:23:17 -04:00
|
|
|
@info = inspector.format(_routes.routes).join("\n")
|
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?
|
|
|
|
render :text => '<p>For security purposes, this information is only available to local requests.</p>', :status => :forbidden
|
|
|
|
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
|