1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add an application controller for internal controllers

This commit is contained in:
Andrew White 2013-12-16 05:52:40 +00:00
parent 9d9f4dac06
commit 1602a70fb4
3 changed files with 23 additions and 18 deletions

View file

@ -0,0 +1,16 @@
class Rails::ApplicationController < ActionController::Base # :nodoc:
self.view_paths = File.expand_path('../templates', __FILE__)
layout 'application'
protected
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?
end
end

View file

@ -1,9 +1,9 @@
require 'rails/application_controller'
require 'action_dispatch/routing/inspector' require 'action_dispatch/routing/inspector'
class Rails::InfoController < ActionController::Base # :nodoc: class Rails::InfoController < Rails::ApplicationController # :nodoc:
self.view_paths = File.expand_path('../templates', __FILE__)
prepend_view_path ActionDispatch::DebugExceptions::RESCUES_TEMPLATE_PATH prepend_view_path ActionDispatch::DebugExceptions::RESCUES_TEMPLATE_PATH
layout -> { request.xhr? ? nil : 'application' } layout -> { request.xhr? ? false : 'application' }
before_filter :require_local! before_filter :require_local!
@ -20,16 +20,4 @@ class Rails::InfoController < ActionController::Base # :nodoc:
@routes_inspector = ActionDispatch::Routing::RoutesInspector.new(_routes.routes) @routes_inspector = ActionDispatch::Routing::RoutesInspector.new(_routes.routes)
@page_title = 'Routes' @page_title = 'Routes'
end end
protected
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?
end
end end

View file

@ -1,6 +1,7 @@
class Rails::WelcomeController < ActionController::Base # :nodoc: require 'rails/application_controller'
self.view_paths = File.expand_path('../templates', __FILE__)
layout nil class Rails::WelcomeController < Rails::ApplicationController # :nodoc:
layout false
def index def index
end end