The ruby-trello gem does a decent job of illustrating how to thread-safe (as much as one can w/ Ruby) authentication, but practically nil on thread-safe 3-Legged OAuth. It took me far longer than I care to admit to get it actually working, but now that I have I thought I’d post an example application.
I primarily deploy my simple webapps on Heroku, so you’ll definitely see some Heroku-isms (e.g. Procfile) in the code repository.
You can see the code in action here.