Rails 3 and the Force.com REST API made easy with Omniauth and Httparty
I wanted to share a sample Ruby on Rails 3 app which includes a custom Omniauth strategy for connecting to Force.com, and uses Httparty to simplify using the REST API
Over the past few months, more and more Ruby developers have asked for some guidelines on how to connect the Force.com platform from a Ruby On Rails 3 applications. The simple answer is to use the REST APIs which went GA in the latest release, Spring 11. The REST APIs certainly make things easier, but there is still the issue of OAuth, which for many, is a steep learning curve.
If you have been to any presentation I have given, you may have heard me quote something from one of my biggest inspirations, the architect Frank Lloyd Wright. Although Wright was an architect is the traditional sense—he designed buildings, not computer systems—he had an amazingly innate perspective of what good architecture should be.
The reason I referring to Wright is that I could have easily put a REST sample out there, but I am a fan of minimalist architecture, and enabling developers to focus on what they need to build not the low level plumbing often associated with traditional software development. To quote Wright, “Simplicity and repose are the qualities that measure the true value of any work of art.”
Ruby, language simplicity aside, has two great gems which really embrace that concept of simplicity: Omniauth for handling authentication, and Httparty for working with http reqests. Both of these gems are extremely relevant for what I wanted to write: a simple Rails3 implementation for working with the Force.com REST APIs.
Long story short, I wrote a custom Omniauth strategy to connect to Force.com, used Httparty to handle my REST calls, and put it all on github with a quick how-to guide to get you started.