0

私の小さな Rails アプリには、say という名前のコントローラーがあり、その中に hello と goodbye の 2 つのページがあります。アプリにデバイスをインストールしました。最初は、/users/sign_in として sing_in ページにアクセスでき、同様にサインアップすることもできました。サインアウトできませんでした。サインアウトできないため、サインアップまたはサインイン ページに再度アクセスできません。ここで、次のコード int eh say/hello ページを入力しました

<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
4

1 に答える 1

1

これが役立つことを願っています

これをroutes.rbで試してください

devise_for :users do get '/users/sign_out' => 'devise/sessions#destroy' end

于 2013-07-03T07:15:49.410 に答える