Rails 4 - 迁移到 Postgresql 后出现 CRUD 错误
Rails 4 - CRUD error after migrating to Postgresql
我刚刚将我的数据库从 sqlite 迁移到 postgresql,我遇到了一些销毁操作的问题,当数据库是 sqlite 时,它工作正常。
请求的参数包含id值且数据库中存在该id
虽然我看到这个错误屏幕,但它会很好地销毁。
我不确定这是在抱怨什么。
控制器
before_action :find_recipe, only: [:show, :edit, :update, :destroy]
...
def destroy
Recipe.destroy(params[:id])
redirect_to :back, notice: "Recipe successfully deleted"
end
private
def find_recipe
@recipe = Recipe.find(params[:id])
end
这个错误似乎与销毁完全无关,它似乎是在试图显示记录。您很可能在销毁记录后重定向回记录的显示页面。
流量:
- /show/5(你点击销毁)
- /destroy/5(销毁记录)
- /show/5(来自redirect_to :back,但ID已不存在)
我刚刚将我的数据库从 sqlite 迁移到 postgresql,我遇到了一些销毁操作的问题,当数据库是 sqlite 时,它工作正常。
请求的参数包含id值且数据库中存在该id 虽然我看到这个错误屏幕,但它会很好地销毁。 我不确定这是在抱怨什么。
控制器
before_action :find_recipe, only: [:show, :edit, :update, :destroy]
...
def destroy
Recipe.destroy(params[:id])
redirect_to :back, notice: "Recipe successfully deleted"
end
private
def find_recipe
@recipe = Recipe.find(params[:id])
end
这个错误似乎与销毁完全无关,它似乎是在试图显示记录。您很可能在销毁记录后重定向回记录的显示页面。
流量:
- /show/5(你点击销毁)
- /destroy/5(销毁记录)
- /show/5(来自redirect_to :back,但ID已不存在)