2014-10-04 77 views
2

我在Heroku上部署了一個應用程序。一切工作正常,除了退出。當我點擊鏈接註銷時,出現以下錯誤:Ruby on Rails:無法退出生產中的應用程序

「您正在查找的頁面不存在,您可能錯誤輸入了地址或頁面可能已移動,如果您是應用程序所有者,請檢查記錄更多信息。「

對於用戶驗證我當然使用設計寶石,我有多個解決方案圍繞堆棧溢出徘徊,但是他們都沒有爲我工作。看看下面的文件。

Heroku的日誌:

2014-10-04T18:17:49.022165+00:00 app[web.1]: Started GET "https://stackoverflow.com/users/sign_out" for 66.65.108.74 at 2014-10-04 18:17:49 +0000 
2014-10-04T18:17:49.027680+00:00 app[web.1]: 
2014-10-04T18:17:49.027702+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/railties-4.1.5/lib/rails/rack/logger.rb:20:in `block in call' 
2014-10-04T18:17:49.027684+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "https://stackoverflow.com/users/sign_out"): 
2014-10-04T18:17:49.027686+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.5/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' 
2014-10-04T18:17:49.027699+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.5/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' 
2014-10-04T18:17:49.027701+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/railties-4.1.5/lib/rails/rack/logger.rb:38:in `call_app' 
2014-10-04T18:17:49.027704+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.5/lib/active_support/tagged_logging.rb:68:in `block in tagged' 
2014-10-04T18:17:49.027711+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call' 
2014-10-04T18:17:49.027706+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.5/lib/active_support/tagged_logging.rb:68:in `tagged' 
2014-10-04T18:17:49.027720+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call' 
2014-10-04T18:17:49.027719+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in `call' 
2014-10-04T18:17:49.027705+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.5/lib/active_support/tagged_logging.rb:26:in `tagged' 
2014-10-04T18:17:49.027708+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/railties-4.1.5/lib/rails/rack/logger.rb:20:in `call' 
2014-10-04T18:17:49.027713+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.5/lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call' 
2014-10-04T18:17:49.027710+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call' 
2014-10-04T18:17:49.027715+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in `call' 
2014-10-04T18:17:49.027724+00:00 app[web.1]: vendor/ruby-2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run' 
2014-10-04T18:17:49.027723+00:00 app[web.1]: vendor/ruby-2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service' 
2014-10-04T18:17:49.027714+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.5/lib/action_dispatch/middleware/static.rb:64:in `call' 
2014-10-04T18:17:49.027718+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/railties-4.1.5/lib/rails/application.rb:144:in `call' 
2014-10-04T18:17:49.027717+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/railties-4.1.5/lib/rails/engine.rb:514:in `call' 
2014-10-04T18:17:49.027709+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.5/lib/action_dispatch/middleware/request_id.rb:21:in `call' 
2014-10-04T18:17:49.027721+00:00 app[web.1]: vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service' 
2014-10-04T18:17:49.027725+00:00 app[web.1]: vendor/ruby-2.1.1/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread' 
2014-10-04T18:17:49.027727+00:00 app[web.1]: 
2014-10-04T18:17:49.027726+00:00 app[web.1]: 

路線:

Rails.application.routes.draw do 
    root 'listings#index' 

    devise_for :users 

    resources :listings 

    get 'pages/about' 
    get 'pages/contact' 

end 

導航:

<ul class="nav navbar-nav navbar-right"> 
     <% if user_signed_in? %> 
      Logged in as <strong><%= current_user.email %></strong>. 
      <%= link_to 'Edit profile', edit_user_registration_path, :class => 'navbar-link' %> | 
      <%= link_to "Logout", destroy_user_session_path, method: :delete, :class => 'navbar-link' %> 
     <% else %> 
      <%= link_to "Sign up", new_user_registration_path, :class => 'navbar-link' %> | 
      <%= link_to "Login", new_user_session_path, :class => 'navbar-link' %> 
     <% end %> 
</ul> 

編輯:

耙潰敗es:

Prefix Verb URI Pattern     Controller#Action 
        root GET /       listings#index 
     new_user_session GET /users/sign_in(.:format)  devise/sessions#new 
      user_session POST /users/sign_in(.:format)  devise/sessions#create 
    destroy_user_session DELETE /users/sign_out(.:format)  devise/sessions#destroy 
      user_password POST /users/password(.:format)  devise/passwords#create 
     new_user_password GET /users/password/new(.:format) devise/passwords#new 
     edit_user_password GET /users/password/edit(.:format) devise/passwords#edit 
         PATCH /users/password(.:format)  devise/passwords#update 
         PUT /users/password(.:format)  devise/passwords#update 
cancel_user_registration GET /users/cancel(.:format)  devise/registrations#cancel 
     user_registration POST /users(.:format)    devise/registrations#create 
    new_user_registration GET /users/sign_up(.:format)  devise/registrations#new 
    edit_user_registration GET /users/edit(.:format)   devise/registrations#edit 
         PATCH /users(.:format)    devise/registrations#update 
         PUT /users(.:format)    devise/registrations#update 
         DELETE /users(.:format)    devise/registrations#destroy 
       listings GET /listings(.:format)   listings#index 
         POST /listings(.:format)   listings#create 
      new_listing GET /listings/new(.:format)  listings#new 
      edit_listing GET /listings/:id/edit(.:format) listings#edit 
       listing GET /listings/:id(.:format)  listings#show 
         PATCH /listings/:id(.:format)  listings#update 
         PUT /listings/:id(.:format)  listings#update 
         DELETE /listings/:id(.:format)  listings#destroy 
      pages_about GET /pages/about(.:format)   pages#about 
      pages_contact GET /pages/contact(.:format)  pages#contact 
+0

嘗試運行'rake routes'來查看/ users/sign_out是否存在。 – mahemoff 2014-10-04 18:34:48

+0

發佈'耙路線'的輸出,請 – Undo 2014-10-04 18:35:09

+0

請問。對於那個很抱歉。 – scrippyfingers 2014-10-04 20:17:00

回答

7

它可能與jQuery有關。

一定要具備以下線在你的application.js文件(應用程序/資產/ Java腳本/ application.js中),任何其他條目之前:

//= require jquery 
//= require jquery_ujs 

速戰速決將是改變signout方法在devise.rb初始化程序(config/initializers/devise.rb):

config.sign_out_via = :get 
+0

嘿@bmsatierf感謝您的回答,我非常感謝。配置我的初始化文件可以很好地工作,但是在任何其他條目不起作用之前需要使用jquery和jquery_ujs。當我進行切換時,它似乎禁用了我的開發中的引導下拉菜單。但在生產中,我的引導程序下拉菜單完全不起作用。 – scrippyfingers 2014-10-05 18:39:18

+0

要使更改在生產中生效,您需要重新編譯資產,「bundle exec rake資產:預編譯」,然後重新啓動服務器 – 2014-10-05 19:29:59

相關問題