Search code examples
ruby-on-rails-3activerecordsalesforcedatabasedotcom-gem

SalesForce databasedotcom gem conflict with ActiveRecord


I encountered strange problem - when Im trying to get User information from SalesForce using databasedotcom gem like this:

owner = client.find("User", deal_from_sf.OwnerId)

I get ActiveRecord error ActiveRecord::RecordNotFound for User, id:0013000000XXXXX

How can I use this method without patching native gem (as I understand alias for find method will help)?


Solution

  • The answer is so simple - read the documentation!!!

    The problem obviously was in the namespace which was Global by default and User treated like ActiveRecord model. But one should add just one line to salesforce.yml file:

    sobject_module : YourModuleName
    

    and specify module where your salesForce logic lives)

    http://rubydoc.info/github/heroku/databasedotcom/master/Databasedotcom/Client#sobject_module-instance_method