Created
November 6, 2014 23:55
-
-
Save feifanzhou/f4719513faa76bf6fd2a to your computer and use it in GitHub Desktop.
Send JS errors to Slack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AlertsController < ApplicationController | |
include SlackHelper | |
def create | |
message = params[:message] || '' | |
slack_post_alert message | |
render nothing: true and return | |
end | |
end | |
module SlackHelper | |
require 'slack/post' | |
def slack_post_alert(message) | |
return unless Rails.env.production? | |
Slack::Post.configure( | |
subdomain: 'YOUR_SLACK_DOMAIN', | |
token: 'SLACK_INTEGRATION_TOKEN', | |
username: 'Oh noes!' | |
) | |
Thread.new { | |
Slack::Post.post message, '#sitealerts' | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
slack-post gem: https://github.com/CozyCo/slack-post