Greg Hauptmann wrote:
Can't I access methods directly after they have been mixed in?
In the code below I get an error at the marked location "undefined local variable or method `current_user' for ApplicationController:Class" even though I've already mixed in the variable into the class. Note that when I use "current_user.login" in another place, for example in an action in a specific controller, it works fine, but just not here in the ApplicationController directly after the mix in.
Can you spot why at all? Tks in advance.
class ApplicationController < ActionController::Base
u = current_user.login <=== ERROR OCCURS HERE
return @active_rbac_user unless @active_rbac_user.nil?
if session[:rbac_user_id].nil? then
current_user is an ApplicationController instance method, which
you can't use in the class context of a class definition.
Perhaps you want to put the setting of u (or @u) in a before_filter.