Ruby on Rails 3 with Salesforce: Conclusion

Rails with Salesforce

Don’t do it.

If you even think about doing it, you’re nuts.

This summarises the conclusion of an article I wrote half a year ago about my attempt to use Salesforce as the primary database for Ruby on Rails.

In details, just before I wrote the previous article, our boss insisted that we use the information we store in a database at Salesforce to run our application made with Ruby on Rails.

I thought he wanted our application to connect to Salesforce only to get the data we need, or to sync a copy of the data present there with our database running on PostgreSQL. But no, he meant all the data should be readable and writable on, and only on, Salesforce.

This meant everything down to the user accounts and the sessions. At that point, we had to replace the entire database abstraction layer with something that would work with Salesforce.

Screenshot of Databasedotcom on GitHub.

We found the closest thing that met our need: the [databasedotcom][] gem for Rails by Heroku. Since Heroku is now owned by Salesforce, they should have something that works seamlessly with their database API and Rails. Right?

I believed they did, but I was only desperate to find anything to help us. Sadly, the gem was poorly maintained and it did not even use the latest version of the API by Salesforce in the time. As I noticed some recent pull requests today, it seems the code is better maintained lately. Or maybe I’m just being hopeful again.

A few months of hard work later, on a separate branch of our application’s code, we came up with something that was workable, but far from being complete. Turns out Salesforce uses special column names and the Salesforce Object Query Language, or SOQL, is far from being on par with the SQL language of many other database systems out there.

As for testing, we did find the vcr gem to be of some use. It allowed us to record remote requests done via API and store their responses in files to commit in our repo. We can reuse them later, to replicate, or “replay”, those requests and responses, even when we don’t have a network connection. This greatly speeds up our tests when they involve remote traffic.

We showed our work, or rather patchwork… Actually, we showed our mess of support for Salesforce crammed into our Rails app to our boss. The application was slower than a snail sliding on glue and it made research papers written on typewriters and sent by mail more efficient.

Needless to say, that project was canned very quick after the presentation, and the boss no longer has any problem with our application using the databasedotcom gem to copy data between Salesforce and PostgreSQL.

In conclusion, to repeat myself, don’t do it.

Leave a Reply