I am using the databasedotcom
gem in a Ruby on rails
app to access my Salesforce instance but I am having some trouble getting an sObject
to be created under the correct namespace. I already have a model called User
in my database, so when I first tried to get a list of User
objects from Salesforce I was getting my locally defined model.
After reading around I found that I can specify a namespace for the client which I use to connect to my Salesforce instance, using sobject_module
. I did that and I also defined a module in my project for the Salesforce models. However I still get back the locally defined User
model rather than the Salesforce defined User
model. If I try to access a model that is present in Salesforce but not locally then the object is returned under the correct namespace.
Why does this happen? I thought once I set the sobject_module
for the client it should return the model under the correct namespace. Here is my client connection:
client = Databasedotcom::Client.new(
client_id: "my_client_id",
client_secret: "my_client_secret",
sobject_module: "Sale"
)
client.oauth_token = client.authenticate( username: "my_username", password: "my_password")
Here is the module i defined for the Salesforce objects:
module Sale
end
This works, it returns <Sale::Organization:0x007f90ef8ad590>
client.materialize("Organization")
However this does not, it returns <User:0x007f8f7e5a06d0>
client.materialize("User")
Thanks in advance
Update
I was not able to get this to work for me, but I found another gem and it worked perfectly with it. I used the restforce
gem