0

我正在尝试了解如何设置新路线,但是我选择的路线不起作用,它只显示“没有路线匹配 [GET]”/users/18/settings“”。

我想做的是创建一个 /settings ,它将显示用户在注册页面 /users/new 上输入并显示在 /users/ID/edit 上的所有信息

路线.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'

结束结束

耙路线:

settings_user GET /users/:id/settings(.:format) users#settings 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 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) 会话#destroy

4

1 回答 1

2

尝试

resources :users do  
    get 'settings', on: :member  
end

对于/users/18/settings

match 'settings' => 'users#settings'

对于/ 设置

于 2013-03-20T16:39:11.730 回答