Skip to content

Instantly share code, notes, and snippets.

@dagobah
Created August 12, 2011 12:41
Show Gist options
  • Save dagobah/1141954 to your computer and use it in GitHub Desktop.
Save dagobah/1141954 to your computer and use it in GitHub Desktop.
How can I get access to the current user here?
###Watered down version, how do I get current_user in the initialize method?
module Protect
extend ActiveSupport::Concern
module ClassMethods
#stuff
end
module InstanceMethods
def initialize (*args, &block)
keys = current_user.keys
# Do some authorization checks
super(*args, &block)
end
end
end
#####
class MyController < ApplicationController
include Protect
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment