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

Querying for all records of a custom object from Ruby/Rails

I'm hoping someone will respond.  So far, I've had no luck on any of my other posts getting someone to respond.


Goal:  Query all records of a custom object type from Rails.


Approaches tried and results:


asf-soap-adapter gem:  doesn't support underscores in object names

asf-rest-adapter gem:  (don't recall why, but this didn't work either)

databasedotcom gem:  .all() method only returns 250 records and there are nearly 900 in Salesforce

salesforce bulk api:  tried several gems that purport to be bulk api gems.  received various errors with every one of them.


Question 1:  Is the bulk api the proper approach here, or should the normal REST api work?  Is there any way to make the databasedotcom gem work in this situation?


Question 2:  If the bulk api is the proper approach, is there an official gem that should be used?  I tried them all, including the one referenced in the Salesforce documentation, without success.


Hoping that someone will read this and provide some direction.




You should be able to do this via the REST API, the query endpoint will chunk up results once the number of rows gets over a threshold, in which case the first response includes the URL of the next page of records, which contains a URL to the next page and so on. So to get all the rows might require a number of API requests.


for the databasedotcom gem, it sounds like .all() is returning all the records in the current page of results, does it expose the URL for the next page of results, so that you can fetch the rest ?




Thank you very much for the pointer.  I was finally able to locate information about this in an issue/bug of the databasedotcom github project.


The answer is as you described:  the .all() method gets the first page of results and the resulting collection object has methods for .next_page? (to determine if there are more pages), and .next_page() to get the next page of records.


It looks like the databasedotcom gem is the "official" gem for interacting with the Salesforce REST API.  If so, what is the "official" way to get support for it?  I have found no descriptions of how to fully use it.  The documentation of the gem/project itself is lacking.  Where can one go for answers?  (I did finally find what I believe to be the answer through much grief and toil.)


Is there any way to get direct support from Salesforce on development issues such as this?  TIA for any further information you can provide.



Bruce Yue -- SF ArchitectBruce Yue -- SF Architect

gem install sfdc


client = username: '' ...

client.query('select id from object')