ruby on rails 3 - Call back to Application Controller error - NameError (undefined local variable or method -
i'm upgrading application rails 2 3. use rights , role approach authentication worked fine under rails 2. in application controller (application.rb) have:
class applicationcontroller < actioncontroller::base
def check_authentication unless session[:user] session[:intended_resource] = request.request_uri session[:intended_action] = action_name session[:intended_controller] = controller_name redirect_to :controller => "sessions", :action => "new" return false end end def check_authorization user = user.find(session[:user]) unless user.roles.detect{|role| role.rights.detect{|right| right.action == action_name && right.controller == self.class.controller_path } } flash[:notice] = "you not authorized view page requested" request.env["http_referer"] ? (redirect_to :back) : (redirect_to :controller => "sessions", :action => "new") return false end end
end
in other controllers i've included before filter.
before_filter :check_authentication,:check_authorization
i'm getting following error message, example, when go dashboard controller.
nameerror (undefined local variable or method `check_authentication' dashboardcontroller:0x0000010291a0c0):
is there else need change or add make work in rails 3?
thanks, aaron
make sure dashboardcontroller inheriting applicationcontroller i.e. dashboardcontroller < applicationcontroller
.
Comments
Post a Comment