2011-05-30 82 views
0

如何設置我的Rails應用程序,以便能夠將Salesforce和PostgreSQL作爲Heroku的後端使用。我目前的代碼是:ActiveSalesforce + Heroku + PostgreSQL + Rails 2.3.x

#environment.rb 
... 
config.gem "asf-soap-adapter", :lib => 'asf-soap-adapter' 
config.database_configuration_file = File.join(RAILS_ROOT, 'config', 'salesforce.yml') 

salesforce.yml包含PostgreSQL和SF的配置。這不起作用,因爲它取代了當前的Heroku database.yml,所以我無法連接到數據庫。

任何想法如何解決這個問題?

回答

0

好的,所以它接縫,我已經想通了: 所有你需要做的是爲後端創建一個單獨的配置文件,例如, 「salesforce.yml」,它看起來像這樣:

development: 
    # usual stuff that you put at your database.yml 

test: 
    # usual stuff that you put at your database.yml 

production: 
    # you need to get following from Heroku (http://devcenter.heroku.com/articles/database#database_urls) 
    host: #host of Herkou db 
    adapter: postgresql 
    encoding: unicode 
    database: # Heroku db name 
    username: # Heroku db username 
    password: # Heroku db password 

salesforce-default-realm: 
    adapter: activesalesforce 
    url: https://www.salesforce.com 
    username: #salesforce username 
    password: #{salesforce_password}{salesforce_security_token} 
    api_version: 20.0 

然後environment.rb中:

... 
config.gem "asf-soap-adapter", :lib => 'asf-soap-adapter' 
config.database_configuration_file = File.join(RAILS_ROOT, 'config', 'salesforce.yml')