An activerecord hook to send notifications to slack on updations and creation of resources.
Add this line to your application's Gemfile:
gem 'slackbot-rails', :git => 'git://github.com/bitsapien/slackbot-rails.git'
And then execute:
$ bundle
Just put the notify_bot
method in your model
class Model < ActiveRecord::Base
notify_bot bot: {
webhook: '<WEBHOOK URL>',
name: '<BOT NAME>',
channel: '#channel-name'
},
message: {
create: 'A new resource in *{class.model_name.human}* was created. '}
end
This would send a notification on Slack:
You may enable/disable notifications using a flag, for example in application.rb
config.slackbot_rails_enable = Rails.env.production?
- Specs!
- Background job option.
- Add I18n support.
- Add fallbacks for configurations.
- Add more support for emojis.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request