From 6f21ef73ad6a56f08b2f48c46e474b3ad4937d39 Mon Sep 17 00:00:00 2001 From: Martin Linkhorst Date: Thu, 13 Feb 2014 11:50:29 +0100 Subject: [PATCH] move application controller load hook to the end of the class definition. find explanation why inside. --- app/controllers/application_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3d59bd4dce..ac33f42a6d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -651,7 +651,6 @@ class ApplicationController < ActionController::Base end true end - ActiveSupport.run_load_hooks(:application_controller, self) def check_session_lifetime if session_expired? @@ -697,4 +696,10 @@ class ApplicationController < ActionController::Base def permitted_params @permitted_params ||= PermittedParams.new(params, current_user) end + + # active support load hooks provide plugins with a consistent entry point to patch core classes. + # they should be called at the very end of a class definition or file, so plugins can be sure everything has been loaded. + # this load hook allows plugins to register callbacks when the core application controller is fully loaded. + # good explanation of load hooks: http://simonecarletti.com/blog/2011/04/understanding-ruby-and-rails-lazy-load-hooks/ + ActiveSupport.run_load_hooks(:application_controller, self) end