2017-10-02 7 views
-1

ユーザーを編集するためのルートを取得できません。編集ルートを取得できません

<li><%= link_to "Settings", edit_user_path(current_user) %></li> 

routes.rb

Rails.application.routes.draw do 

    root 'static_pages#home' 

    get 'help' => 'static_pages#help' 
    get 'about' => 'static_pages#about' 
    get 'contact' => 'static_pages#contact' 
    get 'contact' => 'static_pages#contact' 
    get 'signup' => 'users#new' 
    get 'login' => 'sessions#new' 
    post 'login' => 'sessions#create' 
    delete 'logout' => 'sessions#destroy' 

    get '/all_users', :to => 'users#index' 

    get '/users/:id', :to => 'users#show', :as => :user 

    resources :users do 
    get user 
    end 

    resources :account_activations, only: [:edit] 
end 

EDIT

私は

get 'edit' => 'static_pages#edit' 
を追加以下

は、編集、ユーザーがリンクしている_header.html.erb、あります

と同じ問題がありますが、それはUrlGenerationErrorがあると言います。

+0

以下の回答が役に立たなかった場合は、質問を更新し、エラーメッセージ全体を追加することをおすすめします。 – Oxfist

答えて

0

削除:

get '/all_users', :to => 'users#index' 

get '/users/:id', :to => 'users#show', :as => :user 

get user 
end 

と使用:

resources :users do 
    resources :account_activations, only: [:edit] 
end 

あなたを与えるだろう。

edit_user_account_activation GET /users/:user_id/account_activations/:id/edit(.:format)  account_activations#edit 
         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 
0

あなたはちょうどこのようなルートを作成する必要があります。

> resources :users do 
//extra routes goes here if you want to make out of it 
end 

レールコンソールにrake routesまたはbundle exec rake routesを実行すると、生成されたルートが表示されます。

関連する問題