我正在使用rails 3.1.3(我相信最新版本),並在我的應用程序中使用gem Devise進行用戶身份驗證。爲了增加用戶顯示(配置文件)頁,我添加了一個Users_Controller.rb
設計用戶顯示頁面控制器不工作
class UsersController < ApplicationController
before_filter :authenticate_user!
def show
@userProfile = User.find(params[:id])
@user = current_user
@title = @userProfile.name
end
end
,並在routes.rb
文件我有resources :users
。 我也有一個簡單的app/views/users/show.html.erb
。 現在,當我手動進入本地主機:3000 /用戶/ 1,但當我嘗試鏈接到配置文件<%=link_to "My Profile", user_path(@user) %>
(這是在我的applicationcontroller.rb
incase重要)時,這一切工作正常和花花公子我得到一個操作控制器:異常No route matches {:action=>"show", :controller=>"users"}
但是,當我耙路線,動作表演和控制器用戶出現。我究竟做錯了什麼!!! 請幫忙!!
啊我想通了。而不是@user它應該是current_user – Vasseurth