零以下是完整的错误:设计CURRENT_USER =在ApplicationController中
Can't verify CSRF token authenticity
User Load (0.3ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 5 ORDER BY `users`.`id` ASC LIMIT 1
(0.1ms) BEGIN
(0.2ms) COMMIT
Completed 500 Internal Server Error in 22ms
NoMethodError - undefined method `has_role?' for nil:NilClass:
app/controllers/application_controller.rb:8:in `authenticate_admin_user!'
我可以确认我是在用管理用户的时间登录。
这里是触发错误的控制器:
class ApplicationController < ActionController::Base
def authenticate_admin_user!
unless current_user.has_role? :admin
flash[:alert] = "This area is restricted to administrators only."
redirect_to main_app.root_path
end
end
你发送给您的应用程序,以及如何什么要求?看起来你错过了一个CSRF令牌。 – 2014-10-06 07:20:53