在production.rb中,我有以下单行的config.action_mailer ..
config.action_mailer.default_url_options = { :host => 'secret-brushlands- 1375.herokuapp.com' }
在Development.rb中我(这似乎工作BTW)
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { :host => 'localhost:3000'}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {:address => "localhost", :port => 1025}
在Environment.rb中我有:
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV['sendgrid user'],
:password => ENV['sendgrid password'],
:domain => 'heroku.com',
:enable_starttls_auto => true
}
我们很抱歉,但出了点问题。
出于某种原因,我的heroku应用程序出现此错误(仅限于此 当我尝试sign_up时,用户部分发生了另一个模型 postgresql上的功能似乎很酷) - 我做了一个heroku PG:复位 heroku运行rake:db:migrate等等但无济于事。
这是我的宝石文件:
source 'https://rubygems.org'
gem 'rails', '4.1.0'
gem 'pg'
gem 'foundation-rails'
gem 'rails_12factor', group: :production
gem 'devise'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'tzinfo'
gem 'tzinfo-data'
这是heroku日志:
2014-04-24T17:34:53.598955+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
iverecord-4.1.0/lib/active_record/transactions.rb:329:in `block in
with_transact
ion_returning_status'
2014-04-24T17:34:53.598952+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
iverecord-4.1.0/lib/active_record/attribute_methods/dirty.rb:21:in
`save'
2014-04-24T17:34:53.598961+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
iverecord-4.1.0/lib/active_record/connection_adapters/abstract/database_statemen
ts.rb:211:in `transaction'
2014-04-24T17:34:53.598957+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
iverecord-4.1.0/lib/active_record/connection_adapters/abstract/database_statemen
ts.rb:211:in `block in transaction'
2014-04-24T17:34:53.598959+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
iverecord-4.1.0/lib/active_record/connection_adapters/abstract/database_statemen
ts.rb:219:in `within_new_transaction'
2014-04-24T17:34:53.599212+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
iverecord-4.1.0/lib/active_record/transactions.rb:326:in
`with_transaction_retur
ning_status'
2014-04-24T17:34:53.599214+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
iverecord-4.1.0/lib/active_record/transactions.rb:268:in `block in save'
2014-04-24T17:34:53.599209+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
iverecord-4.1.0/lib/active_record/transactions.rb:208:in `transaction'
2014-04-24T17:34:53.599215+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
iverecord-4.1.0/lib/active_record/transactions.rb:283:in
`rollback_active_record
_state!'
2014-04-24T17:34:53.599228+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/callbacks.rb:229:in `block in
halting'
2014-04-24T17:34:53.599218+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/dev
ise-3.2.4/app/controllers/devise/registrations_controller.rb:15:in
`create'
2014-04-24T17:34:53.599223+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_controller/metal/rendering.rb:10:in
`process_action'
2014-04-24T17:34:53.599220+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_controller/metal/implicit_render.rb:4:in
`send_action'
2014-04-24T17:34:53.599231+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/callbacks.rb:229:in `block in
halting'
2014-04-24T17:34:53.599217+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
iverecord-4.1.0/lib/active_record/transactions.rb:267:in `save'
2014-04-24T17:34:53.599224+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/abstract_controller/callbacks.rb:20:in `block in
process_actio
n'
2014-04-24T17:34:53.599230+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/callbacks.rb:229:in `call'
2014-04-24T17:34:53.599233+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/callbacks.rb:166:in `call'
2014-04-24T17:34:53.599227+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/callbacks.rb:113:in `call'
2014-04-24T17:34:53.599221+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/abstract_controller/base.rb:189:in `process_action'
2014-04-24T17:34:53.599225+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/callbacks.rb:113:in `call'
2014-04-24T17:34:53.599234+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/callbacks.rb:166:in `block in
halting'
2014-04-24T17:34:53.599237+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/callbacks.rb:166:in `block in
halting'
2014-04-24T17:34:53.599239+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/callbacks.rb:166:in `call'
2014-04-24T17:34:53.599236+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/callbacks.rb:166:in `call'
2014-04-24T17:34:53.599258+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/callbacks.rb:166:in `call'
2014-04-24T17:34:53.599262+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/callbacks.rb:149:in `block in
halting_and_co
nditional'
2014-04-24T17:34:53.599260+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/callbacks.rb:149:in `call'
2014-04-24T17:34:53.599263+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/callbacks.rb:149:in `call'
2014-04-24T17:34:53.599256+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/callbacks.rb:166:in `block in
halting'
2014-04-24T17:34:53.599266+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/callbacks.rb:86:in `call'
2014-04-24T17:34:53.599265+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/callbacks.rb:149:in `block in
halting_and_co
nditional'
2014-04-24T17:34:53.599276+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/abstract_controller/callbacks.rb:19:in
`process_action'
2014-04-24T17:34:53.599259+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/callbacks.rb:166:in `block in
halting'
2014-04-24T17:34:53.599268+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/callbacks.rb:86:in `run_callbacks'
2014-04-24T17:34:53.599278+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_controller/metal/rescue.rb:29:in
`process_action'
2014-04-24T17:34:53.599282+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/notifications/instrumenter.rb:20:in
`instrum
ent'
2014-04-24T17:34:53.599286+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_controller/metal/params_wrapper.rb:250:in
`process_acti
on'
2014-04-24T17:34:53.599284+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/notifications.rb:159:in `instrument'
2014-04-24T17:34:53.599281+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/notifications.rb:159:in `block in
instrument
'
2014-04-24T17:34:53.599279+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_controller/metal/instrumentation.rb:31:in
`block in pro
cess_action'
2014-04-24T17:34:53.599322+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
iverecord-4.1.0/lib/active_record/railties/controller_runtime.rb:18:in
`process_
action'
2014-04-24T17:34:53.599325+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionview-4.1.0/lib/action_view/rendering.rb:30:in `process'
2014-04-24T17:34:53.599285+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_controller/metal/instrumentation.rb:30:in
`process_acti
on'
2014-04-24T17:34:53.599324+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/abstract_controller/base.rb:136:in `process'
2014-04-24T17:34:53.599327+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_controller/metal.rb:195:in `dispatch'
2014-04-24T17:34:53.599332+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_dispatch/routing/route_set.rb:80:in `call'
2014-04-24T17:34:53.599338+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_dispatch/routing/mapper.rb:45:in `call'
2014-04-24T17:34:53.599341+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_dispatch/journey/router.rb:71:in `block in
call'
2014-04-24T17:34:53.599330+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_controller/metal.rb:231:in `block in action'
2014-04-24T17:34:53.599329+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_controller/metal/rack_delegation.rb:13:in
`dispatch'
2014-04-24T17:34:53.599334+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
2014-04-24T17:34:53.599345+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_dispatch/journey/router.rb:59:in `call'
2014-04-24T17:34:53.599336+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_dispatch/routing/route_set.rb:48:in `call'
2014-04-24T17:34:53.599343+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_dispatch/journey/router.rb:59:in `each'
2014-04-24T17:34:53.599347+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_dispatch/routing/route_set.rb:676:in `call'
2014-04-24T17:34:53.599355+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/war
den-1.2.3/lib/warden/manager.rb:34:in `catch'
2014-04-24T17:34:53.599357+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/war
den-1.2.3/lib/warden/manager.rb:34:in `call'
2014-04-24T17:34:53.599363+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/rac
k-1.5.2/lib/rack/head.rb:11:in `call'
2014-04-24T17:34:53.599353+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/war
den-1.2.3/lib/warden/manager.rb:35:in `block in call'
2014-04-24T17:34:53.599359+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/rac
k-1.5.2/lib/rack/etag.rb:23:in `call'
2014-04-24T17:34:53.599369+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/rac
k-1.5.2/lib/rack/session/abstract/id.rb:225:in `context'
2014-04-24T17:34:53.599361+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/rac
k-1.5.2/lib/rack/conditionalget.rb:35:in `call'
2014-04-24T17:34:53.599367+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_dispatch/middleware/flash.rb:254:in `call'
2014-04-24T17:34:53.599370+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/rac
k-1.5.2/lib/rack/session/abstract/id.rb:220:in `call'
2014-04-24T17:34:53.599365+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_dispatch/middleware/params_parser.rb:27:in
`call'
2014-04-24T17:34:53.599376+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
iverecord-4.1.0/lib/active_record/connection_adapters/abstract/connection_pool.r
b:621:in `call'
2014-04-24T17:34:53.599372+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_dispatch/middleware/cookies.rb:560:in `call'
2014-04-24T17:34:53.599374+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
iverecord-4.1.0/lib/active_record/query_cache.rb:36:in `call'
2014-04-24T17:34:53.599389+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_dispatch/middleware/show_exceptions.rb:30:in
`call'
2014-04-24T17:34:53.599380+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/callbacks.rb:82:in `run_callbacks'
2014-04-24T17:34:53.599384+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
2014-04-24T17:34:53.599382+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
2014-04-24T17:34:53.599378+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_dispatch/middleware/callbacks.rb:29:in `block
in call'
2014-04-24T17:34:53.599391+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/rai
lties-4.1.0/lib/rails/rack/logger.rb:38:in `call_app'
2014-04-24T17:34:53.599386+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_dispatch/middleware/debug_exceptions.rb:17:in
`call'
2014-04-24T17:34:53.599393+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/rai
lties-4.1.0/lib/rails/rack/logger.rb:20:in `block in call'
2014-04-24T17:34:53.599398+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/tagged_logging.rb:26:in `tagged'
2014-04-24T17:34:53.599396+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/tagged_logging.rb:68:in `block in
tagged'
2014-04-24T17:34:53.599440+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/rac
k-1.5.2/lib/rack/methodoverride.rb:21:in `call'
2014-04-24T17:34:53.599488+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/rac
k-1.5.2/lib/rack/runtime.rb:17:in `call'
2014-04-24T17:34:53.599433+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_dispatch/middleware/request_id.rb:21:in `call'
2014-04-24T17:34:53.599414+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/rai
lties-4.1.0/lib/rails/rack/logger.rb:20:in `call'
2014-04-24T17:34:53.599400+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/tagged_logging.rb:68:in `tagged'
2014-04-24T17:34:53.599493+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ionpack-4.1.0/lib/action_dispatch/middleware/static.rb:64:in `call'
2014-04-24T17:34:53.599491+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/act
ivesupport-4.1.0/lib/active_support/cache/strategy/local_cache_middleware.rb:26:
in `call'
2014-04-24T17:34:53.599495+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/rac
k-1.5.2/lib/rack/sendfile.rb:112:in `call'
2014-04-24T17:34:53.599497+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/rai
lties-4.1.0/lib/rails/engine.rb:514:in `call'
2014-04-24T17:34:53.599499+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/rai
lties-4.1.0/lib/rails/application.rb:144:in `call'
2014-04-24T17:34:53.599501+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/rac
k-1.5.2/lib/rack/lock.rb:17:in `call'
2014-04-24T17:34:53.599503+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/rac
k-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
2014-04-24T17:34:53.599502+00:00 app[web.1]:
vendor/bundle/ruby/2.0.0/gems/rac
k-1.5.2/lib/rack/content_length.rb:14:in `call'
2014-04-24T17:34:53.599506+00:00 app[web.1]:
vendor/ruby-2.0.0/lib/ruby/2.0.0/
webrick/httpserver.rb:94:in `run'
2014-04-24T17:34:53.599505+00:00 app[web.1]:
vendor/ruby-2.0.0/lib/ruby/2.0.0/
webrick/httpserver.rb:138:in `service'
2014-04-24T17:34:53.599509+00:00 app[web.1]:
2014-04-24T17:34:53.599508+00:00 app[web.1]:
vendor/ruby-2.0.0/lib/ruby/2.0.0/
webrick/server.rb:295:in `block in start_thread'
2014-04-24T17:34:53.599510+00:00 app[web.1]:
2014-04-24T17:34:53.588804+00:00 app[web.1]:
2014-04-24T17:34:53.588813+00:00 app[web.1]: Sent mail to
tstevens_21@earthlink.
net (66.7ms)
2014-04-24T17:34:53.595347+00:00 app[web.1]: Completed 500 Internal
Server Error
in 389ms
2014-04-24T17:34:53.600317+00:00 heroku[router]: at=info method=POST
path=/users
host=secret-brushlands-1375.herokuapp.com
request_id=052e3b18-a726-49ae-b816-1b
b5b13c8367 fwd="216.40.153.100" dyno=web.1 connect=3ms service=408ms
status=500
bytes=1754
我正在使用Devise,我在Heroku上安装了SendGrid。哈文没见过 电子邮件确认。任何帮助表示赞赏。
谢谢,
答案 0 :(得分:0)
在config/environment.rb
文件中,更改smtp_settings的配置如下:
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'], ## Refer to key SENDGRID_USERNAME
:password => ENV['SENDGRID_PASSWORD'], ## Refer to key SENDGRID_PASSWORD
:domain => 'heroku.com',
:enable_starttls_auto => true
}
之后,通过运行以下命令在heroku环境中添加环境变量SENDGRID_USERNAME
和SENDGRID_PASSWORD
:
heroku addons:add sendgrid:starter