Favorite

I love Rails, Ruby and Heroku. If I need to get something that works live and on the web right now, I know I can trust these tools to the ends of the earth.

The other day I had 30 minutes to do just that.

The Schwad Awards

Dundies

For either 9 or 10 years now (no one is quite sure), every holiday season I have been doing the Schwad Awards. For the first few years they were public on twitter, then I moved them to the more private-and-taggable world of Facebook.

What are the Schwad Awards? They started off as an opportunity to make up jokes and have ended up being a ‘sort-of-dundies’ where a great deal of my friends get nods of affection via an award. Could be an inside joke, a general compliment. (i.e. “The Award for Person Most Likely To Aspirate a Jalapeño goes to Bob Smith! 🙊”)

Funnily enough, I’ve started doing so many of them that they take up a good chunk of time. Once someone has gotten a ‘Schwad Award’ three years in a row, it’s quite a slight to leave them out. It always grows, never shrinks.

This year was particularly interesting for the awards.

Schwad gets married

Let me back up. WAY up. Over four years after our first date, I got to be the luckiest man on the planet and marry my sweetheart last December. Biggest day of our lives by a mile. We spent nearly two years saving and the amount of planning was off the charts.

I promised that on New Years Eve this year, as I’ll have just been married, I would not be spending half the night slowly writing out Facebook schwad award posts.

Around that time I made a post (jokingly) saying that the Schwad Awards would happen ‘during’ the wedding day and only be awarded to those in attendance.

I forgot about this until the week before the wedding, when I found out a fair few guests actually were expecting this to happen! I didn’t worry - Facebook has the tooling to allow me to write these out in advance, my plan was to have them drip out on social networking at a steady pace during the time between the ceremony and the dinner. I figured it would be a nice treat while my wife and I were away taking all of our photos.

WRONG

As I discovered during the 30 minutes I had allocated myself to write the awards before leaving for the venue Facebook does NOT allow post scheduling. This was only a feature I had gotten used to on my official facebook pages. Yep. We had a problem.

WHAT DO I DO NOW 🚨 😵

Shock

Don’t panic, I told myself. In the scheme of things the Schwad Awards really do not matter at all, they can be left behind. But I still had 29.5 minutes. With the pressure off, I thought simply: ‘what do I need to make this work?

I needed text online.

I needed it to become available at only a prespecified time.

I needed only my facebook friends to be able to read it.

Rails and Heroku to the Rescue

Instead of using the limited social networking tooling I whipped out the sharp sword of Ruby on Rails to solve my problem, and fast. I had my app to work with in seconds.

rails new save_my_bacon --database=postgresql

Under a minute later I had my routes, controller and linked view created. To test timing in development I checked:

  - if Time.now < end_of_wedding_ceremony
    %h2= "The Schwad Awards will be released at #{end_of_wedding_ceremony}"
  - else
    ....

Perfect. All I needed was:

git init

And then:

heroku create please-save-my-bacon

And finally:

git push heroku master

And boom! I was live in under five minutes! I had the rest of the 25 minutes to build out a very rudimentary HTML based table with the data I wanted. Thanks Heroku! ❤️

Let’s make sure only my friends see this

One more important thing was to protect these awards from the ‘wide open world’ of the web.

Normally my authentication is done with Devise, but for a time like this I just needed a simple username and password blocker that I would share on my facebook page. Luckily Rails has slick support for this with HTTP Basic authentication.

Taken straight from the guides here, you can implement this in any Rails controller in seconds like so:

  class AdminsController < ApplicationController
    http_basic_authenticate_with name: "humbaba", password: "5baa61e4"
  end

Sweet! And I was off to the races!

Dundies

All’s well….

Thanks to these wonderful tools we have at our disposal, I was able to solve a surprise problem in a fraction of an hour and move on with my life (and my wedding!). I completely forgot about it until some attendees were commenting on their awards over drinks during the reception.

❤️ Rails + Heroku ❤️

Stay in Touch

I like to write about Ruby and building things, typically once every month or so. Get an email when I have written something new.