Я обновляю приложение с Rails 2 до 3. Я использую подход с правами и ролями для аутентификации, которая отлично работала под Rails 2. В моем Application Controller (application.rb) у меня есть:
класс ApplicationController
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.
before_filter :check_authentication,:check_authorization
Я получаю следующее сообщение об ошибке, например, при переходе к контроллеру панели инструментов.
NameError (undefined local variable or method `check_authentication' for DashboardController:0x0000010291a0c0):
Что-то еще мне нужно изменить или добавить, чтобы это работало в Rails 3?
Спасибо,
Аарон