views:

74

answers:

2

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. 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.

A: 

This is a standard Rails error message. 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.

Also note that record.delete is different than record.destroy. The first one doesn't execute associated callbacks.

Simone Carletti
He did. destroy calls callbacks, like removing children, if specified with :dependent => :destroy. Delete simply removes the row.
Matchu
+1  A: 

Did you save the database and close the SQLite browser? 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.

Matchu
u are right, the db is locked.
Ted Wong