Dev Blog


registered list of MIME Media Types

Heroku SSL Certs

After a battle with SSL and Heroku last night, I thought it wise to shared some hang-ups others might encounter.

Heroku has some decent documentation. If you need to purchase an SSL certificate, go here, which explains purchasing through DNSimple, then go here which tells you how to add your new certificate to Heroku. Heroku has recently changed their default way of doing SSL to Endpoint-based SSL. They’re deprecating nearly every other method in favor of this one, which behaves a bit more rationally. If you’re on Hostname-based, switching over to Endpoint is a synch.

CAVEATS!

  • Heroku’s “Prepare Certificate” section in the first link tells you to download the rapidSSL .pem intermediate certificates and add them to your public certificate. While this is great and all, it’s not enough and will raise security warnings on all versions of Firefox <= 11 (which is quite recent). I believe the rapidSSL certs only apply to domain-specific SSL certificates, not wildcard certificates. After you purchase your certificate, Comodo will send you a zip with 4 files, your public certificate, some intermediate certificates, and the root CA certificate (perhaps most important of all!). Follow this blog post from here on out, and you will be in good shape.

  • Heroku sends you your *.herokussl.com endpoint after you add certificates, not after you add the add-on. While their documentation, read carefully, says this, I still got confused why we never received an email about it after adding the add-on.

find_each, not all

This great presentation at RailsConf 2012 by James Edward Grey II pointed out something I hadn’t taken into account. This:

User.all do |user| # do something... end

is bad mojo for potential large tables because it will attempt to load the entire table into memory. A better habit to get into is:

User.find_each do |user| # do something... end

This will have the same net result, but it will only pull 1000 records at a time into memory.

Silence!

As great as the Rails asset pipeline is, I don’t understand the need for it to punish your log with overly-verbose output. Why not only only log missed assets? Why must I be told on every request that all 13 stylesheets/javascripts were fetched? Moreover, why doesn’t Rails itself provide a simple way to turn this off? Nevertheless, a gem exists to do just that:

gem 'quiet_assets'

Boom.

Git auto-complete

I’ve recently become a big fan of using git branches more regularly in my coding. My biggest frustration was the internal struggle between descriptive branch names and having to remember/type it every time I needed to make a small change in master. Enter git auto-complete:

http://www.codethatmatters.com/2010/01/git-autocomplete-in-mac-os-x/

Works great.