Quick Tip: Sending Google Chart links via email

Recently I had a client who wanted to deliver reports via email that contained a bunch of charts, and we decided on using Google Charts for the chart rendering. I used the googlecharts gem to create the links to Google. I encountered a problem with the charts not showing up in Gmail, even when the exact same code was working when viewing the reports at the site in the browser.

It turns out that the pipe character used to delimit data, options, etc., in Google Charts URLs didn't play nicely with Gmail. Once they were encoded (converted to %7c), it worked like a champ. So, in my (html) email views, I have this as the src attribute to image tags:

Gchart.line(..., :format => 'url').gsub('|', '%7C')

Problem solved. :)