slack_notification
Demo app - Receive Staging/Production exception notifications in Slack Channel
Required gems
Prerequisite
- Create a channel named “exceptions” in your Slack account
- Get Web Hook URL - click here
Integrate Slack Notification in your Rails app
- Add required gems in Gemfile
gem ‘exception_notification’
gem ‘slack-notifier’
- Install bundle
bundle install
- Add below code in file /config/environments/staging.rb
config.middleware.use ExceptionNotification::Rack,
slack: {
webhook_url: "https://YOUR-SLACK-WEB-HOOK-URL",
channel: "#exceptions",
username: "staging-exception", # ENV based username to distinguish Staging Exceptions in channel
additional_parameters: {
icon_emoji: ":large_blue_circle:", # BLUE CIRCLE icon to distinguish Staging Exceptions in channel
mrkdwn: true
}
}
- Add below code in file /config/environments/production.rb
config.middleware.use ExceptionNotification::Rack,
slack: {
webhook_url: "https://YOUR-SLACK-WEB-HOOK-URL",
channel: "#exceptions",
username: "production-exception", # ENV based username to distinguish Production Exceptions in channel
additional_parameters: {
icon_emoji: ":red_circle:", # RED CIRCLE icon to distinguish Production Exceptions in channel
mrkdwn: true
}
}