ユーザのパスワードをリセットして忘れた場合に備えて電子メールで彼に送信するシステムをプロジェクトに追加しました。昨日(それを実装したとき)うまくいきました。今日、サーバーを起動しようとしたときに、次のエラーが発生しました。 Rails 3.2.1のActionMailerで未定義のメソッド 'default_content_type ='
=> 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>'
この
は私がActionMailer::Base.default_content_type = "text/html"
行をコメントアウトした場合、サーバは問題なく動作します私の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"
です。しかしそれがなければ、私は電子メールを送ることができません。
私は、「バンドルのアップデート」を実行し、すべての結果なしでレールを再インストールして、昨日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を再起動して試してみたのconfig /環境/ development.rbファイルにこれを追加しました。
Ruby 1.9.3でRails 3.2.1を使用しています。助けてください。
DEFAULT_CONTENT_TYPEが必要とされない試すことができます。メールを送信しようとすると、どのようなエラーが発生しますか?また、送信しようとしているメールの適切な表示拡張機能もありますか? (action.format.template) – AMIT
私は質問で、システム全体が昨日うまくいっていたと言いました。私はその行をenvironment.rbに追加するまで電子メールを送信していませんでした。 htmlのためのビュー拡張を作成しましたが、テキストは作成していません。 –