def show
@item = Item.find(params[:id])
rescue ActiveRecord::RecordNotFound #customer with that id cannot be found
redirect_to action: :index
end
/////////////////////////////////////////////////////////////////////////
def edit
@item = Item.find(params[:id])
rescue ActiveRecord::RecordNotFound #customer with that id cannot be found
redirect_to action: :index
end
现在问题在于它没有找到我的数据存在于数据库中。当我把新的数据,然后它工作正常,但只有当我需要更新或显示用户需求的数据。然后它说没有找到记录,但同时新的输入数据可以放入数据库中,就像我之前告诉过你的那样。使用Ruby on Rails无法通过MySql中的ID查找数据
你尝试过执行轨控制台上的查询和看到的结果显示 – Bijendra
给像@item = Item.find一试(PARAMS [:ID] .to_i) – Ranzit
我更新ucing轨控制台的值,但我没能这样做使用代码....我也试过这@item = Item.find(params [:id] .to_i)但没有任何改变....我卡在这里请帮助???????? – Thinkerzz