[英]databasedotcom gem sobject issue
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. 我在
Ruby on rails
应用程序中使用databasedotcom
gem来访问我的Salesforce实例,但是在以正确的名称空间创建sObject
时遇到了一些麻烦。 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. 我的数据库中已经有一个名为
User
的模型,因此当我第一次尝试从Salesforce获取User
对象的列表时,我正在获取本地定义的模型。
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
. 阅读后,我发现可以使用
sobject_module
为客户端指定名称空间,该名称空间用于连接到我的Salesforce实例。 I did that and I also defined a module in my project for the Salesforce models. 我做到了,并且在我的项目中为Salesforce模型定义了一个模块。 However I still get back the locally defined
User
model rather than the Salesforce defined User
model. 但是,我仍然返回本地定义的
User
模型,而不是Salesforce定义的User
模型。 If I try to access a model that is present in Salesforce but not locally then the object is returned under the correct namespace. 如果我尝试访问Salesforce中存在但本地没有的模型,则该对象将在正确的名称空间下返回。
Why does this happen? 为什么会这样? I thought once I set the
sobject_module
for the client it should return the model under the correct namespace. 我认为,一旦为客户端设置了
sobject_module
,它应该在正确的命名空间下返回模型。 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: 这是我为Salesforce对象定义的模块:
module Sale
end
This works, it returns <Sale::Organization:0x007f90ef8ad590>
这有效,它返回
<Sale::Organization:0x007f90ef8ad590>
client.materialize("Organization")
However this does not, it returns <User:0x007f8f7e5a06d0>
但这不是,它返回
<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 我使用了
restforce
宝石
我认为您已经得出了这个结论,但是Heroku不再维护databasedotcom gem。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.