blairanderson
11/29/2016 - 6:24 PM

the evolution of a slack attachment (from ruby object to attachment definition)

the evolution of a slack attachment (from ruby object to attachment definition)

Lets say you have an AR object. I like to quickly get the data into slack and see what is worth keeping/ignoring...

attachments = object.as_json.map { |key, value| {title: "#{key}: #{value}"} unless value.nil? }
message = {
  text: "some JSON",
  attachments: attachements
}

poster = Slack::Poster.new(channel_webhook_url)
poster.send_message(message)