我在Heroku上部署了一个应用程序。一切正常,除了退出。当我点击链接退出时,我收到此错误:
“您要查找的页面不存在。您可能输错了地址或页面可能已移动。如果您是应用程序所有者,请查看日志以获取更多信息。”
对于用户身份验证,我当然使用设计宝石,我有多个解决方案在Stack Overflow上徘徊,但它们都没有为我工作。看看下面的文件。
Heroku Logs:
2014-10-04T18:17:49.022165+00:00 app[web.1]: Started GET "/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] "/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>
修改
Rake Routes:
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 :(得分:7)
它可能与jQuery有关。
在任何其他条目之前,请务必在application.js文件(app / assets / javascripts / application.js)中包含以下行:
//= require jquery
//= require jquery_ujs
快速解决方法是更改devise.rb初始化程序(config / initializers / devise.rb)上的signout方法:
config.sign_out_via = :get