Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mitsuhirookuno/c27157de153f200cf10345c0f1ce739b to your computer and use it in GitHub Desktop.
Save mitsuhirookuno/c27157de153f200cf10345c0f1ce739b to your computer and use it in GitHub Desktop.
良い実装か?は置いていて、controllerのconcernsをmodelから利用するやつ
module SlackHelper
extend ActiveSupport::Concern
# メッセージを通知します
def self.send_to_slack(message, channel:, mentions: nil, icon: ':fukurouchan:')
mentions_line = SlackHelper.create_mentions_line(mentions)
SlackHelper.send_core(mentions_line + message, channel, icon_emoji: icon)
end
delegate :send_to_slack, to: SlackHelper
class Hoge < ApplicationRecord
def foobar
SlackHelper.send_to_slack('test model', channel: 'infra')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment