我正在配置我的應用程序通過gmail smtp發送電子郵件,所以我在production.rb
文件中編寫action_mailer
安裝程序。如何將SMTP配置放置在單獨的文件上?
雖然我不想讓我的gmail憑證寫在production.rb
文件中,這是git版本化的。
這是我到目前爲止做出:
生產RB:
require "SmtpData"
config.action_mailer.default_url_options = {:host => 'my server's ip'}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
enable_starttls_auto: "true",
address: SmtpData::ADDRESS,
port: SmtpData::PORT,
domain: "pjforex.com",
authentication: :plain,
:user_name => SmtpData::USER,
:password => SmtpData::PASS
}
然後,我創建config/initializers/smtp_data.rb
包含:
class SmtpData
USER = '[email protected]'
PASS = 'password'
ADDRESS = "smtp.gmail.com"
PORT = "587"
end
但是當我Capistrano的嘗試預編譯的資產,我得到:
rake aborted!
uninitialized constant SmtpData
關於如何解決這個問題的任何線索。或更好的方法來解決這個問題?
感謝,
有趣,我可以通過通常的提取名稱來引用文件嗎? –
@dongiulio你的意思是從另一個Capistrano任務獲取鏈接文件的列表?當然,爲什麼不呢。或者是其他東西? – bredikhin
我的意思是,我如何引用這些變量來將它們鏈接到正確的配置? –