0

在我们的 rails 应用程序中,我们希望在启动期间加载邮件服务器配置。这是我们在 config/environment/development.rb 中的内容:

  #Action Mailer
  config.action_mailer.smtp_settings = eval(Authentify::AuthentifyUtility.find_config_const('development_smtp_setting'))

Authentify::AuthentifyUtility.find_config_const('development_smtp_setting')应返回:

 {  
   :address              => "mymail.com",  
    :port                 => 587,    
    :user_name            => "smtp_login_name",  
    :password             => "password",  
    :authentication       => :plain,
    :enable_starttls_auto => false
  }

但是rails server抛出错误:

activerecord-3.2.12/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
: ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)

在加载期间似乎没有数据库连接。加载邮件服务器配置的正确方法是什么?谢谢。

4

1 回答 1

2

你需要从数据库加载它吗?通常,您要么从文件加载,要么从环境变量加载。也看看config.after_initialize http://guides.rubyonrails.org/configuring.html#rails-general-configuration

于 2013-09-22T04:59:37.297 回答