2013-04-22 68 views
0

我得到一個非常令人沮喪的錯誤,我認爲這是一個簡單的修復。在我的頭,當我嘗試包括一個名爲「我的帳戶」的路由到用戶的個人資料,我得到的鏈接:設計路由問題

No route matches {:action=>"show", :controller=>"users"} 

其他一切作品在註冊方面/同色器件,我可以去在本地主機登錄後,用戶的個人資料頁:3000 /用戶/ 1

在視圖中我的鏈接代碼:

<%= link_to "My Account", user_path %> 

另外,我想路由到用戶編輯配置文件時,得到完全相同的錯誤page「edit_user_registration_path」:

<%= link_to "Edit Profile", edit_user_registration_path, class: "prof-btn" %> 

我也試過:

<%= link_to "Edit Profile", edit_user_registration_path(@user), class: "prof-btn" %> 

但同樣的錯誤。

我的routes.rb文件:

根: 'static_pages#家' ActiveAdmin.routes(個體經營) devise_for:admin_users,ActiveAdmin :: Devise.config devise_for:用戶 資源:用戶

我users_controller.rb:

類UsersController < ApplicationController的

def show 
    @user = User.find(params[:id]) 
end 

def create 
    @user = User.create(params[:user]) 
end 

def edit 
    @user = User.find(params[:id]) 
end 

enter image description here

任何幫助,將不勝感激!

回答

1

您必須將用戶傳遞給路徑助手。

<%= link_to "My Account", user_path(current_user) %> 
+0

謝謝!這解決了它 – Zephyr4434 2013-04-23 01:25:20