Let's first discuss about debugging a code. During development, suppose you have pushed some changes, then you need to test each and every functionality to check whether your code breaks or not, which is actually impossible. Suppose some part of your code is throwing exceptions, and you are not aware of that but the end user is facing issues because of that. So it is better to have a solution that automatically sends notifications to the developers and admin's whenever an exception comes in the code.
In rails we have a beautiful gem exception_notification that does the work for us. The documentation of the gem can be found at Exception Notifier in Rails.
Here I am explaining how to set up this in your application.
Step 1: Add the gem to your Gemfile.
Step 2: Run the bundle.
Step 3: Configure the action mailer for sending notifications via Email. You can have any configurations for sending emails you like. For sending emails using gmail see this link. Sending Emails in Rails using Gmail. To make exception notifier work, you need to put this code into your production.rb. For testing purpose we are placing the code inside development.rb too.
Now whenever their will be an exception in your code an email will be sent automatically to all the emails that are passed in exception_recipients. A project with full integration of exception notifier and email integration can found here https://github.com/raghvendra1501/sendemail-using-gmail-rails. Do the following to get an exception mail in that project.
Clone the Repository
Produce some bugs in the code
Run the rails server
Place your gmail username and password in config/development.rb
Place a reveiver email in the exception_recipients
Now whenever you will produce an error in the code, an exception email will be sent to the receiver email
Exception Notifier can also be integrated with these platforms: