我的问题是关于 rails helpers 为我的用户模型 User 生成错误的链接
<%= link_to "delete", user_registration_path(user), :method => :delete, :confirm => "You sure?" %>
生成以下网址:whatever.com/users.1
我的路线.rb:
put "rooms/:id/close" => "rooms#close", :as => "close_room"
devise_for :users, path_names: {sign_in: "login", sign_out: "logout"},
controllers: {omniauth_callbacks: "omniauth_callbacks"}
get "home/index"
resource :user do
# Route GET /user/tandem
get 'tandem', :on => :collection
get 'practice', :on => :collection
end
root :to => 'home#index'
resources :rooms
match '/party/:id', :to => "rooms#party", :as => :party, :via => :get
match '/users/find', :to => "users#find", :as => :find_users, :via => :get
# Sample resource route (maps HTTP verbs to controller actions automatically):
match '/users/edit/:id', :to => "users#edit", :as => :edit_user, :via => :get
resources :users, only: [:index ,:show, :edit, :update]
我正在使用 ruby '1.9.3'、'rails'、'3.2.13'、devise(2.2.4)。编辑操作也会发生这种情况。编辑:我的路线文件是
close_room PUT /rooms/:id/close(.:format) rooms#close
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_omniauth_authorize GET|POST /users/auth/:provider(.:format)
omniauth_callbacks#passthru {:provider=>/facebook/}
user_omniauth_callback GET|POST /users/auth/:action/callback(.:format) omniauth_callbacks#(?-mix:facebook)
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
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
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
home_index GET /home/index(.:format) home#index
tandem_user GET /user/tandem(.:format) users#tandem
practice_user GET /user/practice(.:format) users#practice
user POST /user(.:format) users#create
new_user GET /user/new(.:format) users#new
edit_user GET /user/edit(.:format) users#edit
GET /user(.:format) users#show
PUT /user(.:format) users#update
DELETE /user(.:format) users#destroy
root / home#index
rooms GET /rooms(.:format) rooms#index
POST /rooms(.:format) rooms#create
new_room GET /rooms/new(.:format) rooms#new
edit_room GET /rooms/:id/edit(.:format) rooms#edit
room GET /rooms/:id(.:format) rooms#show
PUT /rooms/:id(.:format) rooms#update
DELETE /rooms/:id(.:format) rooms#destroy
party GET /party/:id(.:format) rooms#party
find_users GET /users/find(.:format) users#find
users GET /users(.:format) users#index
POST /users(.:format) users#create
GET /users/new(.:format) users#new
GET /users/:id/edit(.:format) users#edit
GET /users/:id(.:format) users#show
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy