简体   繁体   English

红宝石无法手动删除记录吗?

[英]The ruby on rails can't manually delete records?

I have a database the have orders, and which order many order items, that kinds of thing. 我有一个数据库,其中有订单,以及要订购许多订单项的东西。 I deleted one product carelessly, and it is related to the order items, so it can't load successfully. 我粗心地删除了一个产品,它与订单项有关,因此无法成功加载。 So, I use the SQLite Database Browser to delete the orders and order items. 因此,我使用SQLite数据库浏览器删除订单和订单项。 But after I restart the server, it prompt me that : 但是,当我重新启动服务器后,它提示我:

We're sorry, but something went wrong. 我们很抱歉,但有些不对劲。 We've been notified about this issue and we'll take a look at it shortly. 我们已收到有关此问题的通知,我们将尽快对其进行研究。

Notice that I am using the development mode. 请注意,我正在使用开发模式。

Did you save the database and close the SQLite browser? 您是否保存了数据库并关闭了SQLite浏览器? Your database may be locked. 您的数据库可能已锁定。

You may also have forgotten to delete certain orders, so it's looking for a product that doesn't exist. 您可能还忘记了删除某些订单,因此它正在寻找不存在的产品。

In the future, make sure you're in development mode, since that tends to offer more descriptive error messages. 将来,请确保您处于开发模式,因为这往往会提供更具描述性的错误消息。

This is a standard Rails error message. 这是标准的Rails错误消息。 You should look the development log to figure out what exactly is happening. 您应该查看开发日志以弄清楚到底发生了什么。

You can manually modify your record as soon as your changes don't break data integrity. 您所做的更改不会破坏数据完整性,您可以手动修改记录。

It's recommended you use ActiveRecord :dependent association option to specify what ActiveRecord should to when a record of that specific class is destroyed. 建议您使用ActiveRecord :dependent关联选项来指定销毁特定类的记录时应使用的ActiveRecord。

Also note that record.delete is different than record.destroy . 另请注意, record.deleterecord.destroy不同。 The first one doesn't execute associated callbacks. 第一个不执行关联的回调。

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

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