gpt4 book ai didi

ruby-on-rails - Rails 3.2.1 中 ActionMailer 中的未定义方法 'default_content_type='

转载 作者:数据小太阳 更新时间:2023-10-29 07:13:49 27 4
gpt4 key购买 nike

我在我的项目中添加了一个系统来重置用户密码并通过电子邮件将密码发送给他,以防他忘记密码。昨天它运行良好(当我实现它时)。当我今天尝试启动服务器时,出现以下错误。

=> Booting WEBrick
=> Rails 3.2.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/actionmailer-3.2.1/lib/action_mailer/base.rb:437:in `method_missing': undefined method `default_content_type=' for ActionMailer::Base:Class (NoMethodError)
from /Users/vinayshenoy/flo-server/config/environment.rb:7:in `<top (required)>'
from /Users/vinayshenoy/flo-server/config.ru:4:in `require'
from /Users/vinayshenoy/flo-server/config.ru:4:in `block in <main>'
from /Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
from /Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
from /Users/vinayshenoy/flo-server/config.ru:1:in `new'
from /Users/vinayshenoy/flo-server/config.ru:1:in `<main>'
from /Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
from /Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
from /Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
from /Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.1/lib/rails/commands/server.rb:46:in `app'
from /Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
from /Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
from /Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.1/lib/rails/commands/server.rb:70:in `start'
from /Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.1/lib/rails/commands.rb:55:in `block in <top (required)>'
from /Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.1/lib/rails/commands.rb:50:in `tap'
from /Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.1/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

这是我的 config/environment.rb 文件

# Load the rails application
require File.expand_path('../application', __FILE__)

# Initialize the rails application
FloServer::Application.initialize!

ActionMailer::Base.default_content_type = "text/html"

如果我注释掉 ActionMailer::Base.default_content_type = "text/html" 行,服务器可以正常工作。但没有它,我无法发送电子邮件。

我昨天将它添加到 config/environments/development.rb 文件中

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:user_name => 'username',
:password => 'password',
:authentication => 'plain',
:enable_starttls_auto => true }

我已经尝试重新启动 Mac,运行“bundle update”并重新安装 rails,但没有任何结果。

我在 Ruby 1.9.3 上使用 Rails 3.2.1。请帮忙。

最佳答案

你可以试试

ActionMailer::Base.default :content_type => "text/html"

关于ruby-on-rails - Rails 3.2.1 中 ActionMailer 中的未定义方法 'default_content_type=',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9696487/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com