我正在將應用程序從Rails 2升級到3.我使用權限和角色方法進行驗證,在Rails 2下正常工作。在我的應用程序控制器( application.rb中)我有:回調應用程序控制器錯誤 - NameError(未定義的本地變量或方法
類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 are not authorized to view the page you requested"
request.env["HTTP_REFERER"] ? (redirect_to :back) : (redirect_to :controller => "sessions", :action => "new")
return false
end
end
末在我的其他控制器我已經包含了之前過濾
。before_filter :check_authentication,:check_authorization
我收到以下錯誤消息,例如,當我轉到我的儀表板控制器時。
NameError (undefined local variable or method `check_authentication' for DashboardController:0x0000010291a0c0):
有什麼我需要改變或添加使這項工作在Rails 3?
感謝, 亞倫
Anukul,我檢查了一下,那沒關係。 – Aaron 2010-12-02 01:03:02