我讨厌发布另一个关于这个的话题,因为似乎有十几个,但我找不到任何可以为我解决这个问题的话题。
在我的application.html.erb
我有:
<% if user_signed_in? %>
Logged in as <strong><%= current_user.email %></strong>.
<%= link_to 'Settings', edit_user_registration_path %> |
<%= link_to "Log out", destroy_user_session_path, method: :delete %>
<% else %>
<%= link_to "Sign up", new_user_registration_path %> |
<%= link_to "Log in", new_user_session_path %>
<% end %>
routes
看起来像这样:
devise_for :users,
path_names: {sign_in: "login", sign_out: "logout"}
resources :users
resources :addresses
root 'users#index'
get 'dashboard', to: "users#dashboard"
我的本地日志如下所示:
started GET "/users/logout" for 127.0.0.1 at 2013-10-21 17:47:21 -0700
Processing by UsersController#show as HTML
Parameters: {"id"=>"logout"}
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
Rendered users/show.erb within layouts/application (1.2ms)
因此,像许多其他主题一样,它试图logout
作为id
. 我的链接:delete
中有application.html.erb
,所以不是这样。
这是我的内容application.js
:
//= require jquery
//= require jquery_ujs
//= require_tree .
这看起来不错。
有任何想法吗?我被难住了...
编辑:输出来自rake routes
Prefix Verb URI Pattern Controller#Action
new_user_session GET /users/login(.:format) devise/sessions#new
user_session POST /users/login(.:format) devise/sessions#create
destroy_user_session DELETE /users/logout(.: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
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PATCH /users/:id(.:format) users#update
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
addresses GET /addresses(.:format) addresses#index
POST /addresses(.:format) addresses#create
new_address GET /addresses/new(.:format) addresses#new
edit_address GET /addresses/:id/edit(.:format) addresses#edit
address GET /addresses/:id(.:format) addresses#show
PATCH /addresses/:id(.:format) addresses#update
PUT /addresses/:id(.:format) addresses#update
DELETE /addresses/:id(.:format) addresses#destroy
root GET / users#index
dashboard GET /dashboard(.:format) users#dashboard
send_im_home_text GET /im_home(.:format) users#im_home