尝试链接到“user_annversary_path”并且正在传递不正确的周年纪念路径。user_id 是正确的(2)但 id(周年纪念日)应该是 1。
ActiveRecord::RecordNotFound in AnniversaryController#show
Couldn't find Anniversary with id=2
Rails.root: /Users/nelsonkeating/Desktop/ReminDeal
Application Trace | Framework Trace | Full Trace
app/controllers/anniversary_controller.rb:10:in `show'
Request
Parameters:
{"user_id"=>"2",
"id"=>"2"}
周年纪念控制器
def show
@user = current_user
@anniversary = Anniversary.find(params[:id])
end
查看触发传入的参数不正确的代码
<%= link_to "Anniversary", user_anniversary_path(@user) %>
路线
resources :users do
resources :anniversary
end