我試圖創建後續/取消關注按鈕,但我有錯誤在我的索引行動:爲什麼params [:id]是零?
沒有ID找不到用戶
users_controller.rb:
class UsersController < ApplicationController
before_filter :authenticate_user!
def index
@user = User.find(params[:id])
end
end
我發現params[:id]
是nil
。我對Rails很新,我不明白爲什麼它是nil
。
任何人都可以解釋我做錯了什麼?
你是否在你的請求中加入了'id'參數? – shem 2013-05-12 06:49:15
您使用類型/用戶/ put_id_here的網址 – av501 2013-05-12 06:49:33