In my local Ruby on Rails project, I ran into an issue after making some changes to the database. Something got screwed up my newly created resource
pins, so to fix that I:
1. destroyed the resource
$ rails destroy scaffold pins
2. created a migration file to drop the tables associated with it
$ rails generate migration DropPinsTable
3. Added the this content to the newly created migration file:
class DropPinsTable < ActiveRecord::Migration def up drop_table :pins end def down raise ActiveRecord::IrreversibleMigration end end
4. ran the migration
$ rake db:migrate
5. Regenerated the resource
$ rails generate scaffold pins
New tables were automatically created again, but they were using the same name as the resource I just destroyed. I had a suspicion this might cause an issue when deploying to heroku, and it did.
git push heroku master and
heruoku run rake db:migrate, I saw this error when visiting the index page for my newly created resource on heroku:
The fix turned out to be much easier than I expected, thanks to some sage advice found on stackoverlow.
All I had to do was reset the database:
$ rails heroku run db:reset
After that everything worked fine, no error message. Magic!