Sending email with Gmail and Rails, while supporting multiple Ruby versions

Recently I have been working on a Rails app hosted on our deployment server (Heroku) and trying to get ActionMailer and Ruby working with Gmail’s SMTP service. The one catch is you need to use the TLS protocol and prior to Ruby 1.8.7 (Rails 2.3+) you need to write your own wrapper.

Heroku (still using 1.8.6 on some servers) had a nifty addon (now just a blog post and a Rails plugin) that has a TLS wrapper and configuration for ActionMailer’s  SMTP server settings. Awesome!

But… the plugin still fails to work on a platform with Ruby 1.8.7! Most notably my local development environment. Fortunately the internet is great and solutions can be found.

But… something inside of me still wanted to take advantage of the built in support. So I quickly went ahead and did just that and posted my changes to the Heroku google group (a working alternative to the plugin is mentioned here as well).

Hopefully this helps anyone looking for the same answers as me.

* Update *
Heroku just updated their platform (with a complimentary blog post) to support painless migration to updated deployment stacks (including 1.8.7 and 1.9.1).

Waterloo Region Web Design & Technology meetup: a great event!

Last night we had the pleasure and privilege of presenting at the Waterloo Region Web Design & Technology meetup last night right here in Waterloo, ON at the Barley Works. We had a great time showing off our soon-to-be-released product and got and overwhelmingly positive response. These are some of the tweets about our presentation from last night :-)

I was also very impressed by all of the other presentations from last night! They were:

Corey Dutson (@cdutson) Fast website prototyping using Fireworks CS3: Some great tips for rapid prototyping! Corey showcased several features I didn’t even know existed… like Master Pages

Peter (@TheSignDepot) from The Sign Depot – a great resource if you’ve ever wanted to make a more tangible version of a logo/image for yourself or a client. A great example of how skill and passion of your craft can lead to a great product and a successful company. I know where we’re going when we need a sign for our company :-)

Julia Ouellette (@Jooiah) Tips and tricks in Photoshop. She blew our minds right out the gate with some great features in Photoshop that are really useful and slick, yet not very well known. Great Job Julia!

This is a great event and I would recommend that you attend it if you can. A big thanks goes out to @Jooiah for organizing this great event… and for inviting us to do a demo.

As always, we forgot our camera so I don’t have any pictures to share with you, but if you know of anyone that took pictures and has posted them out there on the Interwebs, please leave a comment below with a link so that we can all enjoy them.

Proxying HTTP Requests in Ruby

So building upon my other jaunts into Ruby I decided to post some code to make http requests to external urls. It could use come polish and there there is most definitely better mechanisms out there (probably a gem or two… or three) but tis fun to write well… code.

First, here is an example of using it.

require 'Proxy'
class HttpCaller
  include Proxy
end

caller = HttpCaller.new

response = caller.call "http://www.somewebsite.com"

if response[:error]
  puts response[:object].message
else
  response[:object].each_header do |key, value|
    puts "#{key}: #{value}"
  end
  puts response[:object].code.to_s
  puts response[:object].body 
end

And I have posted the full code sample here.

Follow

Get every new post delivered to your Inbox.