I use the databasedotcom gem, and at first everything works fine (I am able to list Salesforce resources and perform queries on them), but then at random it drops the connection and gives me

undefined method `[]' for nil:NilClass

for calls such as:

@accounts = Account.all

I am connecting to a dev account via OAuth with token & instance_url obtained by OmniAuth.

It's not hitting any API usage limits (35/5000) so I am wondering what's the problem?

Thank you!

1 Answer 1


The solution was quite simple - I wasn't requesting OAuth with refresh token. You can switch this setting to the Salesforce App (the option is called 'Perform requests on your behalf' in the OAuth scopes).

Then, when you log in via OAuth the hash it provides has additional item called 'refresh_token', you write this down and pass it to Databasedotcom::Client.new alongside client_id and secret every time you instantiate new client.

The docs were a bit scattered and it took me a while to understand the workflow.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .