Created
March 26, 2012 21:57
-
-
Save brand-it/2210076 to your computer and use it in GitHub Desktop.
A nice way to send session data to the active recored.
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
class ApplicationController < ActionController::Base | |
# Your existing stuff | |
around_filter :you_dont_have_bloody_clue | |
protected | |
def you_dont_have_bloody_clue | |
klasses = [ActiveRecord::Base, ActiveRecord::Base.class] | |
methods = ["session", "cookies", "params", "request"] | |
methods.each do |shenanigan| | |
oops = instance_variable_get(:"@_#{shenanigan}") | |
klasses.each do |klass| | |
klass.send(:define_method, shenanigan, proc { oops }) | |
end | |
end | |
yield | |
methods.each do |shenanigan| | |
klasses.each do |klass| | |
klass.send :remove_method, shenanigan | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment