简体   繁体   English

无法在Ruby中使用dabatasedotcom对象

[英]Cannot use dabatasedotcom objects with Ruby

I'm new to Ruby and I'm trying to connect my application with SalesForce using the database.com gem. 我是Ruby的新手,正在尝试使用database.com gem将应用程序与SalesForce连接。 My goal is to develop a gem that wraps the Databasedotcom gem, an than use my own wrapper gem in a rails project. 我的目标是开发一个包装Databasedotcom宝石的宝石,而不是在Rails项目中使用我自己的包装宝石。

I've installed the databasedotcom gem with bundler. 我已经用bundler安装了databasedotcom gem。

My Gemfile has the gem declaration: 我的Gemfile有gem声明:

gem 'databasedotcom'

I've generated my credentials at salesforce (user + pass) and (client_id and client_secret). 我已经在salesforce(用户+通过)和(client_id和client_secret)生成了凭据。 I used a curl script to test the connection and I was even able to connect to my account. 我使用curl脚本测试连接,甚至可以连接到我的帐户。

config/databasedotcom.yml: config / databasedotcom.yml:

host: login.salesforce.com        # Use test.salesforce.com for sandbox
client_secret: mySecret           # This is the Consumer Secret from Salesforce
client_id: myClientID             # This is the Consumer Key from Salesforce
sobject_module: SFDC_Models       # See below for details on using modules
debugging: true                   # Can be useful while developing
username: myusername
password: mypassword

The problem occurs when I'm trying to use the objects inside my code, for example: 当我尝试使用代码中的对象时,会发生问题,例如:

require_relative "test_helper"
class SalesforceclientTest < MiniTest::Test
    def test_send_lead
        client = Databasedotcom::Client.new("databasedotcom.yml")
        client.materialize("User")
        @users = Databasedotcom::User.all()[0..19]
    end
end

When I run rake, it gives me the following error: 运行rake时,出现以下错误:

NameError: uninitialized constant SalesforceclientTest::Databasedotcom NameError:未初始化的常量SalesforceclientTest :: Databasedotcom

I've also tried to put: 我还尝试过:

require databasedotcom

in the beginning of the test code, but than, when I re-run rake, it gives me: 在测试代​​码的开头,但是,当我重新运行rake时,它给了我:

require': cannot load such file -- databasedotcom (LoadError) require':无法加载此类文件-databasedotcom(LoadError)

It's probably something stupid but I can't figure it out. 这可能是愚蠢的,但我无法弄清楚。 Any help? 有什么帮助吗?

Thanks, 谢谢,

Try using: 尝试使用:

require 'databasedotcom' 

With the single quotes. 用单引号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM