我正在尝试了解如何设置新路线,但是我选择的路线不起作用,只显示“无路线匹配[GET]”/ users / 18 / settings“”。
我想要做的是创建一个/设置,显示用户在注册页面/ users / new上输入的所有信息,并显示在/ users / ID / edit
routes.rb中:
Dating::Application.routes.draw do
get 'signup' => 'users#new'
get 'login' => 'sessions#new'
get 'logout' => 'sessions#destroy'
get 'edit' => 'users#edit'
get "/profile/:id" => "users#show"
get "profile/:id/settings" => 'users#edit'
get 'settings', on: :member
match 'settings' => 'users#settings'
resources :users do
resources :sessions
resources :password_resets
resources :galleries
resources :photos
root to: 'users#new'
root to: 'galleries#index'
端 端
rake routes:
settings_user GET /users/:id/settings(.:format)用户#settings GET /users(.:format)用户#index POST /users(.:format)用户#create GET /users/new(.:format)用户#new GET /users/:id/edit(.:format)用户#edit GET /users/:id(.:format)用户#show PUT /users/:id(.:format)用户#update 删除/users/:id(.:format)用户#troy root / users#new
settings /settings(.:format) users#settings
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
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
sessions GET /sessions(.:format) sessions#index
POST /sessions(.:format) sessions#create
new_session GET /sessions/new(.:format) sessions#new
edit_session GET /sessions/:id/edit(.:format)sessions#edit session GET /sessions/:id(.:format)sessions#show PUT /sessions/:id(.:format)sessions#update DELETE /sessions/:id(.:format)sessions#destroy
答案 0 :(得分:2)
尝试
resources :users do
get 'settings', on: :member
end
/ users / 18 / settings 的和
match 'settings' => 'users#settings'
用于 / settings 。