docbrown/app/observers/article_observer.rb
2018-02-28 16:11:08 -05:00

14 lines
456 B
Ruby

class ArticleObserver < ActiveRecord::Observer
def after_save(article)
return if Rails.env.development?
if article.published && article.published_at > 30.seconds.ago
SlackBot.delay.ping "New Article Published: #{article.title}\nhttps://dev.to#{article.path}",
channel: "activity",
username: "article_bot",
icon_emoji: ":writing_hand:"
end
rescue
puts "error"
end
end