Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rake error fixed by bundle exec, but deployment not working

I pushed an update to my Rails app production server, and in the update there was a new database migration. I ran rake db:migrate and got the common error seen here. I ran the rake again in bundle exec bash and it was successful. But after restarting my apache server, I'm now getting the 500 Error page. This update worked fine on my localhost, and was mostly this update to the db with supporting changes in the according view and controller/routing.

I don't even know why this error appeared this time, as I have pushed db updates successfully before using only rake. Nonetheless, the rake was successful. The 500 error page only shows on pages that require that specific new ActiveRecord. Any ideas on how to debug?

EDIT: My problem was an extremely simple one. I merely forgot to include the environment with the rake:

bundle exec rake db:migrate RAILS_ENV=production

Unfortunately, it took quite a while to narrow that down, as I couldn't use IRB to check the db entries until I followed these steps.

like image 1000
Paul Avatar asked Jan 18 '26 14:01

Paul


1 Answers

Did you run rake db:migrate on your server? Also be sure to set the RAILS_ENV flag so your production database is updated:

rake db:migrate RAILS_ENV=production
like image 59
Andrew Theis Avatar answered Jan 21 '26 05:01

Andrew Theis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!