Reputation: 1351
I have a Redmine 2.1.2 server running. In my yet-unported-to-Rails-3 Rails 2 apps, I want to create the 500.html page to have a form that the user can make a Redmine issue about the error, and create it using the Redmine API. However, I'm not sure how to actually "send" the API call from the 500 page since it's a "flat" page (i.e., no controller, views, etc.)
Is it possible to do this in Javascript (seems dangerous)? Or do I somehow need to call one of my Rails controllers from the 500 page, and execute the API from the controller method? I've looked around the internet a little on this topic, but I'm having a hard time finding anything concrete.
Any help would be appreciated.
Upvotes: 1
Views: 769
Reputation: 14068
There are two parts to this. First is that by the time the 500 error is being displayed, it's too late. There's a very good stackoverflow answer on handling dynamic error pages here -- look at the answer that suggests using rescue
(not the accepted answer). That will mean that while something bad has happened, Rails is still running, and you can execute code.
Then you can gather information as needed to create a RedMine issue, and execute a REST request easily using a tool like RestClient, or others.
You may also want to consider the brilliant ExceptionNotifier gem as an alternative. In cases where you have the same exception over and over, you'll end up with a bunch of Redmine issues (or need more complex management to handle this). Exception notifier gives you everything you need in email (I would have it send to a mail group) and then you can enter a single, more constructive Redmine issue.
Upvotes: 0
Reputation: 1025
You can define the error 500 page to access a specific action of your application, like explained here.
And then, on this action you can use some gem to connect to the redmine api. Some examples could be Rest-client or ApiClient.
Upvotes: 1