Accessing Salesforce data from Ruby/Rails

I’ve done some work integrating Rails apps with Salesforce over the past few years, and have been very happy to see the new databasedotcom gem take the place of the community’s older activesalesforce gem. Thanks to work from Heroku and Pivotal Labs, it’s now very easy to push and pull data between a Rails app and your Salesforce organization.

I wrote up an article about using the gem, which is now available on the DeveloperForce site. You can go and check it out at I hope it helps get your started if you’re finding a need to do this sort of work. So many companies rely on Salesforce now for at least their sales pipeline that it can be extremely useful to do things like extract data to show in an internal Rails dashboard, or do more complex reporting. In our case we’re also sourcing data from external places and pushing it into our Salesforce organization so that our sales/support folks can have easy access to it within their Salesforce world.


  1. rwcjr said:

    Great article. Question – if databasedotcom-rails doesn’t support namespacing how would you use it along side global ns? Do you simply not use the databasedotcom-rails gem, or simply not mix global – dbdc naming conventions? Trying to utilize Heroku postgres & dbdc and challenged with best approach. thx again.

  2. Thanks for the comment. I think you’ve got it, those are the two options available. The databasedotcom-rails gem is very convenient, and whether the convenience is worth the tradeoff depends on your usage. Whether it’s a hassle to not mix the naming conventions, on the other hand, also depends on your usage — if the DBDC work is fairly small compared to the rest of your app, then it shouldn’t be too bad to keep things separated, for example (assuming you have enough flexibility over your postgres model/table names).

  3. rwcjr said:

    Struggling with the multiple database – pulling data out of dbdc and inserting into pg – is proving to be a challenge any suggestions?

    • What are the specific challenges you’re facing? In general I’ve found that if I separate things cleanly, with one model for the objects in DBDC and one for the “local” db objects (I use pg as well), then it works pretty well. You’ll inevitably end up with a bit of a “translation” layer between the two, I think, which I’ve handled in the past by adding a “create_from_sfdc()” method in my postgres model, passing in the object extracted from Salesforce. Namespacing the models can also help keep things clean.

      • Bo said:

        just general idiocy on my part. is it possible to provide a very simple example; i know I’m asking too much here, but i’ll take anything you can give me on this one. thanks

      • Well, I’m not sure if this will help or not, but I have a simple example repository here: Maybe it will provide some assistance. I’ve been on some different projects so I haven’t been active on the Salesforce side of things, I’m sorry to say, or else I might have been able to add some more examples to this.

  4. DZwijnenburg said:

    I Think that repository is missing some models… Could you post those, I would lik eto see how you handle SF Objects and “Normal” objects. Thanks

    • That repository doesn’t have any “normal” ActiveRecord models, that’s correct. They would just be handled in the usual way, so it didn’t seem necessary to include any, and I wanted to keep the repository simple. I’m unfortunately not very actively working with Salesforce integration, so this hasn’t been looked at in a while but hopefully it’s still useful to people.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: