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:
parent
9d9f4dac06
commit
1602a70fb4
3 changed files with 23 additions and 18 deletions
16
railties/lib/rails/application_controller.rb
Normal file
16
railties/lib/rails/application_controller.rb
Normal 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
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue