Created
November 6, 2009 11:34
-
-
Save stephanschubert/227945 to your computer and use it in GitHub Desktop.
A small Ruby module which provides access to the current controller everywhere you could need it. Works in multithreaded environments.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module CurrentController | |
def self.included(base) | |
base.before_filter :set_current_controller | |
end | |
def set_current_controller | |
Thread.current[:current_controller] = self | |
end | |
end | |
def current_controller | |
Thread.current[:current_controller] | |
end | |
# Setup it up | |
# ActionController::Base.send :include, CurrentController |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment