我有一个文件config/initializers/secrets.rb包含以下内容:
Rails.configuration.smtp_domain = "derp.com"
Rails.configuration.smtp_password = "derpderp"
Rails.configuration.smtp_user = "derp@derp.com"
Rails.configuration.smtp_address = "derp.derp.com"
在我的config/environments/development.rb我有以下内容:
config.action_mailer.smtp_settings = {
:address => Rails.configuration.smtp_address,
:port => 587,
:domain => Rails.configuration.smtp_domain,
:user_name => Rails.configuration.smtp_user,
:password => Rails.configuration.smtp_password,
:authentication => 'login',
:enable_starttls_auto => true
}
现在,当bundle exec rails c
我收到此错误时:
`method_missing': undefined method `smtp_address' for #<Rails::Application::Configuration:0x007f8c4505b238> (NoMethodError)
但是,如果我将 smtp 配置注释掉,那么在控制台中我可以这样做:
Loading development environment (Rails 3.2.1)
irb(main):001:0> Rails.configuration.smtp_address
=> "derp.derp.com"
不过,我不能在生产中对此发表评论!任何帮助将不胜感激,谢谢!