Reputation: 110980
here's what happened. I used to have a Model called Message, I then wanted to rename it so I created a migration that renamed that table from Message to Thread. I had later migrations that then added to that table.
That worked fine, it terms of db:migrate to move forward with our existing databases. Now I noticed that when I do a db:create to create a fresh db it fails, as rails creates Message, then when it goes to add a field to message I get a:
uninitialized constant AddActiveMessageIdToWalls::Message
I think the problem is that I also renamed all the controller & models from message to thread and now the migration can't find the model when migrating? Does that sound right?
How do you deal with this in the rails world? Thanks
Upvotes: 0
Views: 221
Reputation: 514
I like to keep my db/schema.rb updated to avoid this. So when I need to create the db in a new environment, I just need to do the rake db:create
and rake db:schema:load
. No migration is needed.
Upvotes: 3
Reputation: 5320
easiest solution: just add an empty Message < ActiveRecord::Base subclass in the earlier migration.
... migration file ...
class Message < ActiveRecord::Base;end
Upvotes: 0