0

我第一次尝试将我的 rails 3 应用程序部署到 heroku,但它一直在抛出我uninitialized constant Mail::TestMailer (NameError),这是日志文件

2013-01-13T00:35:41+00:00 app[web.1]: => Booting WEBrick
2013-01-13T00:35:41+00:00 app[web.1]: => Rails 3.2.11 application starting in production on http://0.0.0.0:11346
2013-01-13T00:35:41+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-01-13T00:35:41+00:00 app[web.1]: Exiting
2013-01-13T00:35:41+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.11/lib/action_mailer/delivery_methods.rb:43:in `<module:ClassMethods>': uninitialized constant Mail::TestMailer (NameError)
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.11/lib/action_mailer/delivery_methods.rb:41:in `<module:DeliveryMethods>'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.11/lib/action_mailer/delivery_methods.rb:6:in `<module:ActionMailer>'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/application/railties.rb:8:in `each'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/application/railties.rb:8:in `all'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:434:in `eager_load!'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `block in run_initializers'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_missing'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/config/environment.rb:5:in `<top (required)>'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/config.ru:3:in `block in <main>'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands/server.rb:46:in `app'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.3/lib/rack/server.rb:304:in `wrapped_app'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.3/lib/rack/server.rb:254:in `start'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/devise-2.1.2/app/mailers/devise/mailer.rb:1:in `<top (required)>'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:438:in `each'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:438:in `block in eager_load!'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.11/lib/action_mailer/base.rb:326:in `<module:ActionMailer>'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.11/lib/action_mailer/delivery_methods.rb:3:in `<top (required)>'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands/server.rb:70:in `start'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:55:in `block in <top (required)>'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:50:in `tap'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:50:in `<top (required)>'
2013-01-13T00:35:41+00:00 app[web.1]:   from script/rails:6:in `require'
2013-01-13T00:35:41+00:00 app[web.1]:   from script/rails:6:in `<main>'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.11/lib/action_mailer/base.rb:327:in `<class:Base>'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.3/lib/rack/builder.rb:40:in `eval'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/config.ru:in `<main>'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/config.ru:in `new'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.3/lib/rack/builder.rb:51:in `instance_eval'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.3/lib/rack/builder.rb:51:in `initialize'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.3/lib/rack/builder.rb:40:in `parse_file'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.3/lib/rack/server.rb:200:in `app'
2013-01-13T00:35:41+00:00 app[web.1]: => Call with -d to detach
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.11/lib/action_mailer/base.rb:11:in `<top (required)>'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:436:in `eager_load!'
2013-01-13T00:35:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:436:in `each'
2013-01-13T00:35:42+00:00 heroku[web.1]: Process exited with status 1
2013-01-13T00:35:42+00:00 heroku[web.1]: State changed from starting to crashed

我的 Gemfile 看起来像这样

source 'https://rubygems.org'

gem 'rails', '3.2.11'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem "paperclip", "~> 3.0"
gem 'json'
#json parsing from web
gem 'yajl-ruby'
# gem 'rqrcode' #table qrcodes
gem 'rqrcode-rails3' #imageqrcodes
gem 'mini_magick'


gem 'devise'
gem 'simple_form'
gem 'jquery-rails'
gem 'jquery-mobile-rails'
# gem 'activeadmin'
# gem 'nested_form', :git => 'git://github.com/ryanb/nested_form.git'
gem 'cancan'
# gem "select2-rails"
gem 'friendly_id', :git => "git://github.com/norman/friendly_id.git"

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platform => :ruby

  gem 'uglifier', '>= 1.0.3'
  gem 'twitter-bootstrap-rails'
  # gem 'less-rails'
  # gem 'execjs', '1.4.0'
  # gem 'therubyracer', '0.10.2'
end

group :development, :test do
  gem 'mysql2'
end

group :production do
  gem 'pg'
end

由于我使用设计来处理用户注册,所以我认为设计会尝试发送确认电子邮件。但是在我production.rb像这样为 action_mailer 添加了一些配置之后

  config.action_mailer.raise_delivery_errors = false
  config.action_mailer.perform_deliveries = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    address:              'smtp.gmail.com',
    port:                 587,
    tls:                  true,
    domain:               'gmail.com',
    user_name:            'secret@email.com',
    password:             'secret',
    authentication:       'plain',
    enable_starttls_auto: true  
  }

它仍然没有给我错误

提前致谢

4

1 回答 1

1

重命名 Mail 模型时,请务必重命名文件 app/models/mail.rb 并添加迁移以重命名 mails 表以匹配新模型。

于 2013-01-13T03:01:48.537 回答