我正在使用Slack-Notifier gem將Web鉤子添加到我的rails應用程序中。用鬆弛通知gem添加slack web hook到rails應用程序
我想每次在數據庫中創建一個新用戶時觸發一個Web鉤子。
我有以下,但我認爲我的語法是關閉的。我在我的IDE中出現以下錯誤。
def create
@user = User.new(user_params)
if @user.save
@user.send_activation_email
flash[:info] = "Welcome to Pallet! Please check your email to activate your account."
SLACK_NOTIFIER.ping("New Directory User: #{@user: @user.email, @user.discipline}", username: 'notifier', icon_emoji: ':confetti_ball:")
redirect_to charges_path
else
render 'new'
end
end
配置/初始化/ slack.rb
require 'slack-notifier'
SLACK_NOTIFIER = Slack::Notifier.new("https://hooks.slack.com/services/xxxxxx",
channel: '#directory-bot',
username: 'notifier'
)
謝謝。這看起來更好嗎? 'SLACK_NOTIFIER.ping(「New Directory User:#{@ user},#{@user.email},#{@user.discipline}」, username:'notifier',icon_emoji:':confetti_ball:') – rs19