gpt4 book ai didi

ruby-on-rails - rails : check if ID doesn't exist in controller?

转载 作者:太空宇宙 更新时间:2023-11-03 17:34:40 24 4
gpt4 key购买 nike

<分区>

是否可以做到以下几点:

if @user = User.friendly.find(params[:id])
// logic here
else
// do something if user doesn't exist
end

出于某种原因,这会引发以下错误:

ActiveRecord::RecordNotFound

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com