繁体   English   中英

无法在Ruby on Rails中使用sign_out设计gem

[英]unable to use sign_out in ruby on rails devise gem

在我的小型Rails应用程序中,我有一个名为say的控制器,其中有两页问候和再见。 我在应用程序中安装了devise。 最初,我能够以/ users / sign_in的身份访问sing_in页面,并且同样可以进行注册。 我无法退出,由于无法退出,我无法访问注册或再次登录页面。 现在,我在“说/你好”页面中输入了以下代码

<h1>Say#hello</h1>
<% if user_signed_in? %>
Hey signed in as <%= current_user.email %>.Not you? 
<%= link_to "Logout", destroy_user_session_path %>
<% else %>
Hey <%= link_to "Login", new_user_session_path %> or Hey <%= link_to "Logup", new_user_registration_path %>
<% end %>
</p>

这是应用程序的路线页面。

Demo::Application.routes.draw do
devise_for :users
get "say/hello"
get "say/goodbye"
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".

# You can have the root of your site routed with "root"
root :to => "say#hello"
end

每当我访问say / hello页面时,这就是我得到的输出

  Links

Hey signed in as x@gmail.com.Not you? Logout 

当我单击注销时。 它说

No route matches [GET] "/users/sign_out"

当我直接访问users / sign_in时,我被路由到say / hello页面。

我在做什么错? 我应该如何签出?

我也尝试过

destroy_user_session_path, :method => :delete

希望这可以帮助

在您的routes.rb中尝试一下

devise_for:用户确实得到'/ users / sign_out'=>'devise / sessions#destroy'结束

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM