function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Ruby on Rails 3, Heroku's databasecom gem, ActiveRecord



I'm new to development with Salesforce. I've developed Web applications for 15 years, having done both backends and frontends, recently with Ruby on Rails.


At my current position, I'm working with a boss who has strong connections with Salesforce, so naturally, he wants our new Web app to ditch PostgreSQL and exclusively use instead, not just have two databases sync with each other.


After some reading last weekend, I stumbled upon an old gem that no longer has active support (but is still maintained in some forks on GitHub), that is applied on top of Active Record. This sound ideal, but I'm worried about the lack of central support for its development and maintenance.


I also noticed Heroku's "databasecom" and "databasecom-rails" gems, which completely discards Active Record, and tries to take its place. I'm glad to find software that is actively maintained.


However, the first sight of discarding the well-built and proved Active Record sounds completely idiotic.


How do you handle validation? How can you add methods to your models? How can you write automated tests for your models (with RSpec) and features (with Capybara)? There are many questions, along with many potential problems, that come to mind.


So far, the answers I get are rare, and they're not satisfactory. The first come that I heard, about validation, is "you simply just do it all client-side". You mean I just let everyone with JavaScript turned off put whatever they want in our database?


Is there something I'm not getting? Up to this point, I've yet to stumble upon documentation or examples that will shed light on my lack of knowledge of Salesforce. If you have anything that can show me the way, it would be appreciated.


Thank you in advance.


I've been using activesaleforce adapter in my application, but, after long time of optimizations rforce.rb is the only file which has left of this gem.

And the problem was not validations, tests and other rails features, but performance and API calls limitations.

I'm currently on Rails 2, not 3, but don't think that situation has changed significantly -- Rails performs many requests to database and, when use activesalecforce adapter, these requests are transformed to SOAP API calls, one of them may take a few seconds to execute and parse received data. 

Also, API request limits: . Try co count how many requests your application makes to PostgreSQL and see if you fit in Salesforce's API requests limit.


Another issue with ASF adapter -- salesforce does not return all data at once if there're many records, so I had to implement merging of results, which might be complicated if you have a complex query with nested data. e.g. SELECT Name... (Select Subject,... from Tasks), (Select Subject... from Events) from Leads;


I have not used rforcedotcom gem, but, looking at its code I suspect that it may have the same issues with fetching large amounts (a few thousands) of records, because its rforce.rb looks like very similar to ActiveSalsforce's one. Even the name is the same :). Actually, you can try to fetch 3000 records with it and see if it works.


Also, neither ASF nor rforcedotcom gems support metadata API calls, like describeMetadata(), listMetadata(), retrieve() and so on.


IMHO, they are nice to play with, use in some small projects, but not suitable for production applications.


I use the Databasedotcom gem in production.  Let me see if i can shed some light on your situation:


Most importantly, regarding validation and extending models.  If your architecture choice was to use databasedotcom rather than a more typical Rails-ActiveRecord setup, then you are electing to have your persistence layer live on the platform.  I would suggest using Apex when customizing your data model and use's native declarative programming techniques to create validation and custom logic.  If you are not interested in utilizing all of the features of the platform, and would rather maintain your ORM and persistance layer in Ruby, I would suggest revisiting the decision to use databasedotcom exclusively.


Memcached is a popular intermediary for caching REST API calls to SFDC:  Note that Pat Patterson here does not use the dbdc gem but rather calls the SFDC API's directly via HTTP.  Up to you.