1

当我在我的应用程序中单击“退出”时,Heroku 在应该执行 DELETE 请求时对 URL 执行 GET 请求。当我在本地开发环境中单击“退出”时,它会将我退出。

user-users-macbook-air:app user$ heroku run rake routes
           root        /                         home#show
      users GET    /users(.:format)          users#index
            POST   /users(.:format)          users#create
   new_user GET    /users/new(.:format)      users#new
  edit_user GET    /users/:id/edit(.:format) users#edit
       user GET    /users/:id(.:format)      users#show
            PUT    /users/:id(.:format)      users#update
            DELETE /users/:id(.:format)      users#destroy
   sessions POST   /sessions(.:format)       sessions#create
new_session GET    /sessions/new(.:format)   sessions#new
    session DELETE /sessions/:id(.:format)   sessions#destroy
     signup        /signup(.:format)         users#new
     signin        /signin(.:format)         sessions#new
    signout DELETE /signout(.:format)        sessions#destroy

在我的应用程序中单击注销链接后:

user-users-macbook-air:app user$ heroku logs
2012-07-10T00:55:13+00:00 app[web.1]: Started GET "/signout" for 128.36.168.39 at 2012-07-10 00:55:13 +0000
2012-07-10T00:55:13+00:00 app[web.1]: 
2012-07-10T00:55:13+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/signout"):
2012-07-10T00:55:13+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
2012-07-10T00:55:13+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/rack/logger.rb:26:in `call_app'
2012-07-10T00:55:13+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
2012-07-10T00:55:13+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/rack/logger.rb:16:in `call'
2012-07-10T00:55:13+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
2012-07-10T00:55:13+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
2012-07-10T00:55:13+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/request_id.rb:22:in `call'
2012-07-10T00:55:13+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
2012-07-10T00:55:13+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/static.rb:62:in `call'
2012-07-10T00:55:13+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
2012-07-10T00:55:13+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-ssl-1.3.2/lib/rack/ssl.rb:27:in `call'
2012-07-10T00:55:13+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:245:in `fetch'
2012-07-10T00:55:13+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
2012-07-10T00:55:13+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in `lookup'
2012-07-10T00:55:13+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!'
2012-07-10T00:55:13+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/application.rb:220:in `call'
2012-07-10T00:55:13+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
2012-07-10T00:55:13+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/engine.rb:479:in `call'
2012-07-10T00:55:13+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/content_length.rb:14:in `call'
2012-07-10T00:55:13+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/rack/log_tailer.rb:17:in `call'
2012-07-10T00:55:13+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
2012-07-10T00:55:13+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in `service'
2012-07-10T00:55:13+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
2012-07-10T00:55:13+00:00 app[web.1]: 
2012-07-10T00:55:13+00:00 app[web.1]: 
2012-07-10T00:55:13+00:00 app[web.1]:   /usr/local/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
2012-07-10T00:55:13+00:00 heroku[router]: GET glassboard.herokuapp.com/signout dyno=web.1 queue=0 wait=0ms service=9ms status=404 bytes=728
4

2 回答 2

1

我已经看过很多次了。这不是 Heroku 特有的——它发生在用户的浏览器中。

我正在为我的身份验证包使用设计,并且能够通过修改我的路由以允许用户通过使用GETreuest 而不是DELETE.

这是一个众所周知的问题,允许 HTTPGET注销的选项被普遍接受。

请参阅: 没有路线匹配“/users/sign_out”设计rails 3

于 2012-07-10T01:05:37.557 回答
0

No-Script will cause this behavior, if heroku is not 'allowed'. I verified that my page-source, rendered from Heroku, does specify the 'Delete' method, while the heroku logs show a 'Get' was executed, instead, when scripts were blocked.

Therefore, we need to write something into our app that signals the user ala, "Hey buddy, allow scripts to run or you cannot log-out."

The Heroku docs point to this stackoverflow-page as authoritative, so the more info here, the better.

于 2013-06-18T06:03:06.653 回答