Tutorial :displaying errors in rails app. page 500 on heroku apps



Question:

I am deploying an app on Heroku. Though the experience of deploying is good but I am having pain in fixing stuff.

Very first thing is that autoincrement IDs are all messed up between heroku db and my db. So before deploy I have to delete all data from my local app and then push my DB to heroku. If I don't do that then while trying to add a record on heroku app I get duplicate key errors. Is there a way to control autoincrement ids in rails?

Second thing, when there are errors on heroku app. I see the custom 500 error page. We're sorry, but something went wrong (500). Is there a way to show some sort of error message instead? Or I have to depend on heroku logs for that? This is just for development so if some error happens I'd just like to see it on the page itself. Atleast some part of it...

I'm new to Heroku and Rails


Solution:1

autoincrement issue:

maybe using seed data is a better solution for you see http://railscasts.com/episodes/179-seed-data

errors issue:

in the config/environments/production.rb

try replacing

config.action_controller.consider_all_requests_local = false  config.action_controller.perform_caching             = true  config.action_view.cache_template_loading            = true  

by

config.action_controller.consider_all_requests_local = true  config.action_view.debug_rjs                         = true  config.action_controller.perform_caching             = false  

cheers


Solution:2

You might check the Exception Notification plugin to customize how exceptions are handled.

And concerning your db problems, you can push your local database to heroku using heroku db:push


Solution:3

Pushing the data is one thing, but you might want to look into ways to reset the sequence too. On Heroku they use PGSql, so you'd have to look into its documentation.


Solution:4

I had the same problem, and editing config/environments/production.rb didn't help. Then I discovered that for some reason, my Heroku app is running in staging mode. I changed the following line in config/environment/staging.rb:

config.action_controller.consider_all_requests_local = false  

to:

config.action_controller.consider_all_requests_local = true  

And now I can see exception traces in my browser!


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »