avm_69 avm_69 - 2 years ago 74
Ruby Question

Change Ruby on Rails scaffolding order

I have a Ruby on Rails app and I want to deploy it on Heroku. Some errors appear and I think it is because the scaffolding order.

By that, I mean that a class named submissions is first created, but this class references another class named Users that is yet to be created.

This is the error that appears when doing rake db:migrate http://pastebin.com/R83a3rsN

And those are the migrate files and their filename

I guess you mean that:

http://pastebin.com/ig5nHjsj for 20160503205437_create_submissions


http://pastebin.com/q2jABiep for 20160428101834_create_users

Answer Source

Sounds to me like you didn't load the schema into your heroku database. After deploying what happens when you do this:

heroku run rake db:schema:load

Note that sometimes if you're loading up a new app that has an already-established schema, running all the migrations isn't the best way to get the database to the state you want - you should use rake db:schema:load instead. Let me know if this gets your database correct.

After running it you can use heroku run console and then do console commands like User.all to make sure it knows that the users table exists etc.

Don't forget to restart your server after loading the schema, or running db:migrate. For heroku that'd be: heroku restart

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download