[size=medium]ActionController::InvalidAuthenticityToken解决方法[/size]
Rails支持将session放在数据库中管理,当我执行完rake命令,去掉environment.rb里的config.action_controller.session_store这个注释,Rails2.0以上的版本会报一个错,具体如下:
ActionController::InvalidAuthenticityToken in Products#index
Showing products/index.html.erb where line #17 raised:
No :secret given to the #protect_from_forgery call. Set that or use a session store capable of generating its own keys (Cookie Session Store).
于是上网搜搜,解决方法是到这个文件app/controllers/application.rb,看到这样的描述:
# See ActionController::RequestForgeryProtection for details
# Uncomment the :secret if you're not using the cookie session store
protect_from_forgery #:secret => 'be73f1c53c4d8c3b373da4ebfb6599a2'
于是,把#:secret => 'be73f1c53c4d8c3b373da4ebfb6599a2'前的#去掉,再刷新页面,OK。问题解决,顺便记下来备忘。
Rails支持将session放在数据库中管理,当我执行完rake命令,去掉environment.rb里的config.action_controller.session_store这个注释,Rails2.0以上的版本会报一个错,具体如下:
ActionController::InvalidAuthenticityToken in Products#index
Showing products/index.html.erb where line #17 raised:
No :secret given to the #protect_from_forgery call. Set that or use a session store capable of generating its own keys (Cookie Session Store).
于是上网搜搜,解决方法是到这个文件app/controllers/application.rb,看到这样的描述:
# See ActionController::RequestForgeryProtection for details
# Uncomment the :secret if you're not using the cookie session store
protect_from_forgery #:secret => 'be73f1c53c4d8c3b373da4ebfb6599a2'
于是,把#:secret => 'be73f1c53c4d8c3b373da4ebfb6599a2'前的#去掉,再刷新页面,OK。问题解决,顺便记下来备忘。