Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: 'Could not find table' error

I developped a simple rails application that runs perfectly on my development machine.

When I put it on the production server (Phusion Passenger/Nginx), it returns me that error in the my_app/log/production.log file:

ActiveRecord::StatementInvalid (Could not find table 'categories')

What is wrong?

PS: After a naming error, the table name was edited manually but it works great in the development mode. I don't suspect that misnaming error.

like image 312
Zakaria Avatar asked Jul 21 '11 21:07

Zakaria


1 Answers

  1. Make sure you've run your database migrations on the production server

  2. Manually editing tables is a huge no no in Rails. It'll give you more headaches than it is worth. If you need to change something, you're way better of generating a new migration to change it - even if it's just a name change. (You can however rollback the db changes, delete that last migration and create a new one - but like I said - it's more trouble than it's worth)

  3. Make sure your schema xml file is correct or at least matching to the actual schema. You can delete this and run rake:db:migrate to generate a new one.
like image 197
MunkiPhD Avatar answered Sep 24 '22 22:09

MunkiPhD