2013-07-03 106 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