2013-07-03 191 views
0

在我的小型Rails应用程序中,我有一个名为say的控制器,两个页面hello和goodbye。我在应用程序中安装了设计。最初,我能够以/ users/sign_in的身份访问sing_in页面,并且类似地注册。我无法注销,并且由于无法注销,我无法再访问注册或重新登录页面。现在我进入下面的代码INT EH说/你好页无法在轨道上使用红宝石Sign_out设计宝石

<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 

每当我访问发言权/你好页,这是输出我得到

Links 

Hey signed in as [email protected] you? Logout 

当我点击注销。它说

No route matches [GET] "https://stackoverflow.com/users/sign_out" 

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

我在做什么错误?我应该如何sign_out?

我也曾尝试

destroy_user_session_path, :method => :delete 
+0

在您的路由文件中尝试使用devise_for:users,controllers:{ sessions:'sessions'}而不是“devise_for:users”。 AND <%= link_to'logout',destroy_user_session_path,:method =>“DELETE”%>在您的html –

+0

不起作用Bachan – Aravind

+0

它显示相同的错误吗?你的应用程序中有会话控制器吗? –

回答

1

希望能帮助

试试这个在您的routes.rb

devise_for:用户会收到 '/用户/ SIGN_OUT'=>“设计/会话#destroy'end