2015-05-13 73 views
3

我的Rails應用程序突然開始給我下面的錯誤:Rails的:無法驗證CSRF令牌真實性

Can't verify CSRF token authenticity 
ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken): 

我還沒有作出對應用程序進行任何更改,所以我,什麼是完全狼狽造成這個問題。完整的錯誤日誌如下。我取出了真實性標記,但已經確認該標記對當前用戶有效(通過檢查控制檯)。

2015-05-13T01:44:49.038482+00:00 app[web.1]: I, [2015-05-13T01:44:49.038369 #9] INFO -- : Started POST "/projects?auth_token=xxx」 for 76.118.180.235 at 2015-05-13 01:44:49 +0000 
2015-05-13T01:44:49.044865+00:00 app[web.1]: I, [2015-05-13T01:44:49.044762 #9] INFO -- : Completed 422 Unprocessable Entity in 1ms 
2015-05-13T01:44:49.119991+00:00 app[web.1]: I, [2015-05-13T01:44:49.119893 #9] INFO -- : Processing by SpinsController#create as JSON 
2015-05-13T01:44:49.120060+00:00 app[web.1]: I, [2015-05-13T01:44:49.119998 #9] INFO -- : Parameters: {"spin"=>{}, "auth_token"=>」xxx」} 
2015-05-13T01:44:49.120537+00:00 app[web.1]: W, [2015-05-13T01:44:49.120469 #9] WARN -- : Can't verify CSRF token authenticity 
2015-05-13T01:44:49.122935+00:00 app[web.1]: F, [2015-05-13T01:44:49.122841 #9] FATAL -- : 
2015-05-13T01:44:49.122938+00:00 app[web.1]: ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken): 
2015-05-13T01:44:49.122940+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_controller/metal/request_forgery_protection.rb:181:in `handle_unverified_request' 
2015-05-13T01:44:49.122941+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_controller/metal/request_forgery_protection.rb:209:in `handle_unverified_request' 
2015-05-13T01:44:49.122943+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/devise-3.4.1/lib/devise/controllers/helpers.rb:251:in `handle_unverified_request' 
2015-05-13T01:44:49.122945+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_controller/metal/request_forgery_protection.rb:204:in `verify_authenticity_token' 
2015-05-13T01:44:49.122946+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:427:in `block in make_lambda' 
2015-05-13T01:44:49.122948+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:163:in `call' 
2015-05-13T01:44:49.122949+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:163:in `block in halting' 
2015-05-13T01:44:49.122951+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:92:in `call' 
2015-05-13T01:44:49.122952+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:92:in `_run_callbacks' 
2015-05-13T01:44:49.043562+00:00 app[web.1]: I, [2015-05-13T01:44:49.043425 #9] INFO -- : Processing by ProjectsController#create as JSON 
2015-05-13T01:44:49.043630+00:00 app[web.1]: I, [2015-05-13T01:44:49.043582 #9] INFO -- : Parameters: {"project"=>{"name"=>"New Set"}, "auth_token"=>」xxx」} 
2015-05-13T01:44:49.044251+00:00 app[web.1]: W, [2015-05-13T01:44:49.044184 #9] WARN -- : Can't verify CSRF token authenticity 
2015-05-13T01:44:49.047524+00:00 app[web.1]: F, [2015-05-13T01:44:49.047435 #9] FATAL -- : 
2015-05-13T01:44:49.047527+00:00 app[web.1]: ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken): 
2015-05-13T01:44:49.047528+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_controller/metal/request_forgery_protection.rb:181:in `handle_unverified_request' 
2015-05-13T01:44:49.122954+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:734:in `_run_process_action_callbacks' 
2015-05-13T01:44:49.122955+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:81:in `run_callbacks' 
2015-05-13T01:44:49.122957+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/abstract_controller/callbacks.rb:19:in `process_action' 
2015-05-13T01:44:49.122959+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_controller/metal/rescue.rb:29:in `process_action' 
2015-05-13T01:44:49.122961+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action' 
2015-05-13T01:44:49.122962+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/notifications.rb:164:in `block in instrument' 
2015-05-13T01:44:49.122964+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/notifications/instrumenter.rb:20:in `instrument' 
2015-05-13T01:44:49.047530+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_controller/metal/request_forgery_protection.rb:209:in `handle_unverified_request' 
2015-05-13T01:44:49.047532+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/devise-3.4.1/lib/devise/controllers/helpers.rb:251:in `handle_unverified_request' 
2015-05-13T01:44:49.047534+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_controller/metal/request_forgery_protection.rb:204:in `verify_authenticity_token' 
2015-05-13T01:44:49.047535+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:427:in `block in make_lambda' 
2015-05-13T01:44:49.122965+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/notifications.rb:164:in `instrument' 
2015-05-13T01:44:49.122968+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_controller/metal/instrumentation.rb:30:in `process_action' 
2015-05-13T01:44:49.122969+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_controller/metal/params_wrapper.rb:250:in `process_action' 
2015-05-13T01:44:49.122971+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/railties/controller_runtime.rb:18:in `process_action' 
2015-05-13T01:44:49.122973+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/abstract_controller/base.rb:137:in `process' 
2015-05-13T01:44:49.122975+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionview-4.2.0/lib/action_view/rendering.rb:30:in `process' 
2015-05-13T01:44:49.122977+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_controller/metal.rb:195:in `dispatch' 
2015-05-13T01:44:49.122979+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch' 
2015-05-13T01:44:49.122981+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_controller/metal.rb:236:in `block in action' 
2015-05-13T01:44:49.123001+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:73:in `call' 
2015-05-13T01:44:49.123002+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:73:in `dispatch' 
2015-05-13T01:44:49.047537+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:163:in `call' 
2015-05-13T01:44:49.047538+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:163:in `block in halting' 
2015-05-13T01:44:49.047540+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:92:in `call' 
2015-05-13T01:44:49.047541+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:92:in `_run_callbacks' 
2015-05-13T01:44:49.047543+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:734:in `_run_process_action_callbacks' 
2015-05-13T01:44:49.047544+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:81:in `run_callbacks' 
2015-05-13T01:44:49.047546+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/abstract_controller/callbacks.rb:19:in `process_action' 
2015-05-13T01:44:49.123004+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:42:in `serve' 
2015-05-13T01:44:49.123005+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/journey/router.rb:43:in `block in serve' 
2015-05-13T01:44:49.123007+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/journey/router.rb:30:in `each' 
2015-05-13T01:44:49.123008+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/journey/router.rb:30:in `serve' 
2015-05-13T01:44:49.123009+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:802:in `call' 
2015-05-13T01:44:49.123011+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!' 
2015-05-13T01:44:49.047547+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_controller/metal/rescue.rb:29:in `process_action' 
2015-05-13T01:44:49.047549+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action' 
2015-05-13T01:44:49.047550+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/notifications.rb:164:in `block in instrument' 
2015-05-13T01:44:49.047551+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/notifications/instrumenter.rb:20:in `instrument' 
2015-05-13T01:44:49.047553+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/notifications.rb:164:in `instrument' 
2015-05-13T01:44:49.047554+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_controller/metal/instrumentation.rb:30:in `process_action' 
2015-05-13T01:44:49.047555+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_controller/metal/params_wrapper.rb:250:in `process_action' 
2015-05-13T01:44:49.123012+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call' 
2015-05-13T01:44:49.123013+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!' 
2015-05-13T01:44:49.123015+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call' 
2015-05-13T01:44:49.123022+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/builder.rb:59:in `call' 
2015-05-13T01:44:49.123023+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/jquery-fileupload-rails-0.4.4/lib/jquery/fileupload/rails/middleware.rb:14:in `_call' 
2015-05-13T01:44:49.123025+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/jquery-fileupload-rails-0.4.4/lib/jquery/fileupload/rails/middleware.rb:10:in `call' 
2015-05-13T01:44:49.123026+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:35:in `block in call' 
2015-05-13T01:44:49.123027+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `catch' 
2015-05-13T01:44:49.123029+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `call' 
2015-05-13T01:44:49.047556+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/railties/controller_runtime.rb:18:in `process_action' 
2015-05-13T01:44:49.047557+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/abstract_controller/base.rb:137:in `process' 
2015-05-13T01:44:49.047559+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionview-4.2.0/lib/action_view/rendering.rb:30:in `process' 
2015-05-13T01:44:49.047560+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_controller/metal.rb:195:in `dispatch' 
2015-05-13T01:44:49.047561+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch' 
2015-05-13T01:44:49.047562+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_controller/metal.rb:236:in `block in action' 
2015-05-13T01:44:49.047564+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:73:in `call' 
2015-05-13T01:44:49.047588+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:73:in `dispatch' 
2015-05-13T01:44:49.123030+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/etag.rb:24:in `call' 
2015-05-13T01:44:49.123031+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/conditionalget.rb:38:in `call' 
2015-05-13T01:44:49.123033+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/head.rb:13:in `call' 
2015-05-13T01:44:49.123034+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/params_parser.rb:27:in `call' 
2015-05-13T01:44:49.047589+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:42:in `serve' 
2015-05-13T01:44:49.047590+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/journey/router.rb:43:in `block in serve' 
2015-05-13T01:44:49.047592+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/journey/router.rb:30:in `each' 
2015-05-13T01:44:49.047593+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/journey/router.rb:30:in `serve' 
2015-05-13T01:44:49.047594+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:802:in `call' 
2015-05-13T01:44:49.047595+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!' 
2015-05-13T01:44:49.047597+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call' 
2015-05-13T01:44:49.047598+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!' 
2015-05-13T01:44:49.123035+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/flash.rb:260:in `call' 
2015-05-13T01:44:49.123037+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/session/abstract/id.rb:225:in `context' 
2015-05-13T01:44:49.047599+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call' 
2015-05-13T01:44:49.047610+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.2/lib/omniauth/builder.rb:59:in `call' 
2015-05-13T01:44:49.047612+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/jquery-fileupload-rails-0.4.4/lib/jquery/fileupload/rails/middleware.rb:14:in `_call' 
2015-05-13T01:44:49.047613+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/jquery-fileupload-rails-0.4.4/lib/jquery/fileupload/rails/middleware.rb:10:in `call' 
2015-05-13T01:44:49.047614+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:35:in `block in call' 
2015-05-13T01:44:49.047616+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `catch' 
2015-05-13T01:44:49.047617+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `call' 
2015-05-13T01:44:49.123038+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/session/abstract/id.rb:220:in `call' 
2015-05-13T01:44:49.123039+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/cookies.rb:560:in `call' 
2015-05-13T01:44:49.123041+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/query_cache.rb:36:in `call' 
2015-05-13T01:44:49.123042+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call' 
2015-05-13T01:44:49.123044+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call' 
2015-05-13T01:44:49.123045+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:88:in `call' 
2015-05-13T01:44:49.047618+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/etag.rb:24:in `call' 
2015-05-13T01:44:49.047620+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/conditionalget.rb:38:in `call' 
2015-05-13T01:44:49.047621+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/head.rb:13:in `call' 
2015-05-13T01:44:49.047623+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/params_parser.rb:27:in `call' 
2015-05-13T01:44:49.047624+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/flash.rb:260:in `call' 
2015-05-13T01:44:49.047625+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/session/abstract/id.rb:225:in `context' 
2015-05-13T01:44:49.047627+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/session/abstract/id.rb:220:in `call' 
2015-05-13T01:44:49.047628+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/cookies.rb:560:in `call' 
2015-05-13T01:44:49.123046+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:88:in `_run_callbacks' 
2015-05-13T01:44:49.123048+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:734:in `_run_call_callbacks' 
2015-05-13T01:44:49.123049+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:81:in `run_callbacks' 
2015-05-13T01:44:49.123050+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/callbacks.rb:27:in `call' 
2015-05-13T01:44:49.047630+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/query_cache.rb:36:in `call' 
2015-05-13T01:44:49.123051+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/remote_ip.rb:78:in `call' 
2015-05-13T01:44:49.123053+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call' 
2015-05-13T01:44:49.123054+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' 
2015-05-13T01:44:49.123055+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/rack/logger.rb:38:in `call_app' 
2015-05-13T01:44:49.123056+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/rack/logger.rb:22:in `call' 
2015-05-13T01:44:49.047631+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call' 
2015-05-13T01:44:49.047632+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call' 
2015-05-13T01:44:49.047633+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:88:in `call' 
2015-05-13T01:44:49.047635+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:88:in `_run_callbacks' 
2015-05-13T01:44:49.047636+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:734:in `_run_call_callbacks' 
2015-05-13T01:44:49.047637+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:81:in `run_callbacks' 
2015-05-13T01:44:49.047638+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/callbacks.rb:27:in `call' 
2015-05-13T01:44:49.123058+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/request_id.rb:21:in `call' 
2015-05-13T01:44:49.123059+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/methodoverride.rb:22:in `call' 
2015-05-13T01:44:49.123060+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/runtime.rb:18:in `call' 
2015-05-13T01:44:49.123062+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call' 
2015-05-13T01:44:49.123063+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/sendfile.rb:113:in `call' 
2015-05-13T01:44:49.123064+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/engine.rb:518:in `call' 
2015-05-13T01:44:49.123065+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/application.rb:164:in `call' 
2015-05-13T01:44:49.047639+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/remote_ip.rb:78:in `call' 
2015-05-13T01:44:49.047641+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call' 
2015-05-13T01:44:49.047642+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' 
2015-05-13T01:44:49.047643+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/rack/logger.rb:38:in `call_app' 
2015-05-13T01:44:49.047644+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/rack/logger.rb:22:in `call' 
2015-05-13T01:44:49.047645+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/request_id.rb:21:in `call' 
2015-05-13T01:44:49.047646+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/methodoverride.rb:22:in `call' 
2015-05-13T01:44:49.123067+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:576:in `process_client' 
2015-05-13T01:44:49.123068+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:670:in `worker_loop' 
2015-05-13T01:44:49.123070+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:525:in `spawn_missing_workers' 
2015-05-13T01:44:49.123071+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:140:in `start' 
2015-05-13T01:44:49.123072+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/bin/unicorn:126:in `<top (required)>' 
2015-05-13T01:44:49.123074+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `load' 
2015-05-13T01:44:49.123076+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `<main>' 
2015-05-13T01:44:49.123078+00:00 app[web.1]: 
2015-05-13T01:44:49.047648+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/runtime.rb:18:in `call' 
2015-05-13T01:44:49.123079+00:00 app[web.1]: 
2015-05-13T01:44:49.047649+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call' 
2015-05-13T01:44:49.047650+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/rack-1.6.0/lib/rack/sendfile.rb:113:in `call' 
2015-05-13T01:44:49.047651+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/engine.rb:518:in `call' 
2015-05-13T01:44:49.047653+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/application.rb:164:in `call' 
2015-05-13T01:44:49.047654+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:576:in `process_client' 
2015-05-13T01:44:49.047655+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:670:in `worker_loop' 
2015-05-13T01:44:49.047656+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:525:in `spawn_missing_workers' 
2015-05-13T01:44:49.047657+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:140:in `start' 
2015-05-13T01:44:49.047658+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/bin/unicorn:126:in `<top (required)>' 
2015-05-13T01:44:49.047660+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `load' 
2015-05-13T01:44:49.047661+00:00 app[web.1]: vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `<main>' 

正如我敢肯定,網站工作3天前,我恢復了我的代碼想,也許有一個更新的寶石,我使用可能造成的問題。但它似乎並沒有解決這個問題。

是否有其他人遇到類似的錯誤,如果是的話,你知道如何解決它嗎?我已經嘗試從不同的StackOverflow職位多項建議都沒有用(例如,添加「protect_from_forgery有:null_session」我application_controller.rb)

目前,我有我的會話控制器以下:

class SessionsController < ApplicationController 
    skip_before_filter :verify_authenticity_token, 
        :if => Proc.new { |c| c.request.format == 'application/json' } 

而且我有以下線在我application.html.erb

<%= csrf_meta_tags %> 

一些建議後,我增加了以下我application_controller.rb:

before_filter :cor 
    rescue_from ActionController::InvalidAuthenticityToken, :with => :bad_token 

def bad_token 
    Rails.logger.debug("session expired!") 
    end 


    private 
    def cor 
    headers["Access-Control-Allow-Origin"] = "*" 
    headers["Access-Control-Allow-Methods"] = %w{GET POST PUT DELETE}.join(",") 
    headers["Access-Control-Allow-Headers"] = %w{Origin Accept Content-Type X-Requested-With X-CSRF-Token}.join(",") 
    head(:ok) if request.request_method == "OPTIONS" 
    end 

不過,我仍然收到了同樣的錯誤,儘管短:

2015-05-13T02:45:26.893689+00:00 app[web.2]: I, [2015-05-13T02:45:26.893643 #6] INFO -- : Parameters: {"spin"=>{}, "auth_token"=>"xxx"} 
2015-05-13T02:45:26.895581+00:00 app[web.2]: W, [2015-05-13T02:45:26.893966 #6] WARN -- : Can't verify CSRF token authenticity 
2015-05-13T02:45:26.895583+00:00 app[web.2]: I, [2015-05-13T02:45:26.894210 #6] INFO -- : Completed 200 OK in 0ms (ActiveRecord: 0.0ms) 
2015-05-13T02:45:26.728920+00:00 app[web.2]: I, [2015-05-13T02:45:26.728852 #12] INFO -- : Processing by ProjectsController#create as JSON 
2015-05-13T02:45:26.729261+00:00 app[web.2]: W, [2015-05-13T02:45:26.729155 #12] WARN -- : Can't verify CSRF token authenticity 
2015-05-13T02:45:26.729430+00:00 app[web.2]: I, [2015-05-13T02:45:26.729380 #12] INFO -- : Completed 200 OK in 0ms (ActiveRecord: 0.0ms) 
2015-05-13T02:45:26.890043+00:00 app[web.2]: I, [2015-05-13T02:45:26.889933 #6] INFO -- : Started POST "/spins?auth_token=ArpuyxbDyjtyn67r3JgF" for 76.118.180.235 at 2015-05-13 02:45:26 +0000 
2015-05-13T02:45:26.888494+00:00 heroku[router]: at=info method=POST path="/spins?auth_token=ArpuyxbDyjtyn67r3JgF" host=spin360-staging.herokuapp.com request_id=5edd715a-a01d-4558-9aa3-7f2c2c3dc927 fwd="76.118.180.235" dyno=web.2 connect=1ms service=8ms status=200 bytes=324 

回答

5

這往往特別是從另一個應用程序或ping服務(如Pingdom的)搜索機器人或API調用發生。

對於允許跨域請求(如果你有你的網站或外用一些其他服務API),您可以將此代碼添加到您的application_controller.rb

# API POST REGUEST ALLOW CROSS DOMAIN 
    before_filter :cor 
    def cor 
    headers["Access-Control-Allow-Origin"] = "*" 
    headers["Access-Control-Allow-Methods"] = %w{GET POST PUT DELETE}.join(",") 
    headers["Access-Control-Allow-Headers"] = %w{Origin Accept Content-Type X-Requested-With X-CSRF-Token}.join(",") 
    head(:ok) if request.request_method == "OPTIONS" 
    end 

如果沒有API,這個錯誤可能有過期的會話簡單的問題,只是這個代碼添加到您的application_controller.rb

# Resque form for invalid authentificitytoken 
    rescue_from ActionController::InvalidAuthenticityToken, :with => :bad_token 
    def bad_token 
    flash[:warning] = "Session expired" 
    redirect_to root_path 
    end 

在任何情況下,最好添加第二個代碼檢查過期的會話,並不會顯示用戶軌誤差。 當ActionController :: InvalidAuthenticityToken令人困惑時,顯示rails一般錯誤,因爲它不是站點錯誤。

+0

感謝您的建議 - 我實際上是通過iOS應用程序向我的Rails應用程序發送POST請求。我想知道如何認證令牌變得無效?我會嘗試你的建議,並讓你知道他們是否工作。 – scientiffic

+1

1年前,當我嘗試從API應用程序和外部服務發佈數據時,我遇到了同樣的問題。我添加了這兩個方法後,我有新的錯誤。身份驗證令牌已過期,或斷開連接後可能無效。 – Alex

+0

您如何設置身份驗證令牌以便它們不會過期? – scientiffic

2

我們遇到同樣的問題,並最終使用機架cors寶石。它提供了很多靈活性。

只需加入這一行的Gemfile

gem 'rack-cors', :require => 'rack/cors' 

,然後運行bundle install命令。有許多可用的配置選項。欲瞭解更多詳情https://github.com/cyu/rack-cors

0

在您的瀏覽器中啓用cookie。

我在OpenBSD 5.7的發行版adJ上使用0123.版本0.5.3,發現了同樣的問題。應用程序將再次爲我工作,當我啓用了Cookie使用選項-cookie一個w3m:

w3m --cookie http://127.0.0.1:3000 
+0

我不知道爲什麼downvote。我所描述的情況在解釋的上下文中解決了我的問題。 – vtamara

+0

我剛剛投票,因爲這是我正在研究的項目中發生的事情。我還沒有看完,但我認爲關閉cookies可能會傳遞一個空的會話ID? – benc

0

有點遲到了,但如果萬一別人是尋找一個解決方案。

您是否正在發送POST請求至ProjectsController#create?如果是這樣,請嘗試添加

protect_from_forgery with: :null_session, only: [:create] 

ProjectsController的頂部。在功能上它應該與skip_before_action :verify_authenticity_token相同,但不確定是否繼承ApplicationController。如果你想添加你的Proc支票,你可以做

protect_from_forgery with: :null_session, 
    if: Proc.new { |c| c.request.format =~ %r{application/json} } 
相關問題