简体   繁体   English

Rails 4-迁移到Postgresql后出现CRUD错误

[英]Rails 4 - CRUD error after migrating to Postgresql

I've just migrated my database from sqlite to postgresql and I'm encountering some issue with destroy action that was working fine when database was sqlite. 我刚刚将我的数据库从sqlite迁移到了postgresql,并且遇到了一些破坏操作的问题,当sqlite为sqlite时,该操作可以正常工作。

Requested parameter contains id value and this id exists in the database and it will destroy just fine although I see this error screen. 请求的参数包含id值,并且此id存在于数据库中,即使我看到此错误屏幕,它也会销毁。 I'm not sure what this is complaining about. 我不确定这是在抱怨什么。

错误

controller 控制者

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

This error does not appear related to the destroy at all, it appears to be attempting to show the record. 此错误根本与销毁无关,它似乎是在试图显示记录。 Most likely you redirected back to the record's show page after destroying it. 销毁记录后,很可能您将其重定向回记录的显示页面。

Flow: 流:

  • /show/5 (you click destroy) / show / 5(您单击销毁)
  • /destroy/5 (destroys record) / destroy / 5(破坏记录)
  • /show/5 (via redirect_to :back, but the ID no longer exists) / show / 5(通过redirect_to:back,但是ID不再存在)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM