数据库的 Heroku 权限被拒绝 "postgres"
Heroku permission denied for database "postgres"
现在 2 小时以来,我一直在尝试让邮件程序在 heroku 中工作。
我在 rails 上使用 ruby,我的代码工作正常,直到我尝试按照 this 指南使用 gmail 设置邮件程序。
我已将这些行添加到我的 /config/environments/production.rb:
config.action_mailer.default_url_options = { :host => 'gigitt.herokuapp.com' }
Rails.application.routes.default_url_options[:host] = 'gigitt.herokuapp.com'
一切都很好地推送到 heroku 但当我尝试:heroku 运行 rake db:setup
我收到以下错误:
Running `rake db:setup` attached to terminal... up, run.9482
FATAL: permission denied for database "postgres"
DETAIL: User does not have CONNECT privilege.
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:567:in `retrieve_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_handling.rb:87:in `connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/postgresql_database_tasks.rb:8:in `connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/postgresql_database_tasks.rb:17:in `create'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:93:in `create'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:107:in `block in create_current'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:275:in `block in each_current_configuration'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:274:in `each'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:274:in `each_current_configuration'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:106:in `create_current'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/railties/databases.rake:17:in `block (2 levels) in <top (required)>'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:201:in `block in invoke_prerequisites'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:199:in `each'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:199:in `invoke_prerequisites'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:178:in `block in invoke_with_call_chain'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:201:in `block in invoke_prerequisites'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:199:in `each'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:199:in `invoke_prerequisites'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:178:in `block in invoke_with_call_chain'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/app/bin/rake:4:in `<main>'
Couldn't create database for {"adapter"=>"postgresql",
删除这些行后,出现此错误:
2015-04-30T21:15:21.935684+00:00 app[web.1]: ActionView::Template::Error (Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true):
所以我需要这些线条,但它无法使用,有什么想法吗?
rake db:setup
尝试创建数据库,您不能在 Heroku 上使用 rake 执行此操作。你创建了 pg 数据库吗?你说你的代码在邮寄之前工作正常,所以我猜你是这样的。如果你想 运行 迁移,只需 运行 rake db:migrate
.
好的,我让它工作了。这是我的 production.rb:
config.action_mailer.default_url_options = { :host => 'http://gigitt.herokuapp.com' }
Rails.application.routes.default_url_options[:host] = 'http://gigitt.herokuapp.com'
config.action_mailer.delivery_method = :smtp
# SMTP settings for gmail
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: ENV["GMAIL_DOMAIN"],
authentication: "plain",
enable_starttls_auto: true,
user_name: ENV['GMAIL_USERNAME'],
password: ENV['GMAIL_PASSWORD']
}
end
我的.env:
GMAIL_DOMAIN=mail.website.com.com
GMAIL_USERNAME=email@website.com
GMAIL_PASSWORD=password
我将提交推送到 heroku,没有 运行 heroku 运行 rake db:setup 而只是 运行 heroku 运行 rake db:migrate .现在一切正常了:-D
现在 2 小时以来,我一直在尝试让邮件程序在 heroku 中工作。
我在 rails 上使用 ruby,我的代码工作正常,直到我尝试按照 this 指南使用 gmail 设置邮件程序。
我已将这些行添加到我的 /config/environments/production.rb:
config.action_mailer.default_url_options = { :host => 'gigitt.herokuapp.com' }
Rails.application.routes.default_url_options[:host] = 'gigitt.herokuapp.com'
一切都很好地推送到 heroku 但当我尝试:heroku 运行 rake db:setup 我收到以下错误:
Running `rake db:setup` attached to terminal... up, run.9482
FATAL: permission denied for database "postgres"
DETAIL: User does not have CONNECT privilege.
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:567:in `retrieve_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_handling.rb:87:in `connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/postgresql_database_tasks.rb:8:in `connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/postgresql_database_tasks.rb:17:in `create'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:93:in `create'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:107:in `block in create_current'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:275:in `block in each_current_configuration'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:274:in `each'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:274:in `each_current_configuration'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:106:in `create_current'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/railties/databases.rake:17:in `block (2 levels) in <top (required)>'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:201:in `block in invoke_prerequisites'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:199:in `each'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:199:in `invoke_prerequisites'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:178:in `block in invoke_with_call_chain'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:201:in `block in invoke_prerequisites'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:199:in `each'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:199:in `invoke_prerequisites'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:178:in `block in invoke_with_call_chain'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/app/vendor/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/app/bin/rake:4:in `<main>'
Couldn't create database for {"adapter"=>"postgresql",
删除这些行后,出现此错误:
2015-04-30T21:15:21.935684+00:00 app[web.1]: ActionView::Template::Error (Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true):
所以我需要这些线条,但它无法使用,有什么想法吗?
rake db:setup
尝试创建数据库,您不能在 Heroku 上使用 rake 执行此操作。你创建了 pg 数据库吗?你说你的代码在邮寄之前工作正常,所以我猜你是这样的。如果你想 运行 迁移,只需 运行 rake db:migrate
.
好的,我让它工作了。这是我的 production.rb:
config.action_mailer.default_url_options = { :host => 'http://gigitt.herokuapp.com' }
Rails.application.routes.default_url_options[:host] = 'http://gigitt.herokuapp.com'
config.action_mailer.delivery_method = :smtp
# SMTP settings for gmail
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: ENV["GMAIL_DOMAIN"],
authentication: "plain",
enable_starttls_auto: true,
user_name: ENV['GMAIL_USERNAME'],
password: ENV['GMAIL_PASSWORD']
}
end
我的.env:
GMAIL_DOMAIN=mail.website.com.com
GMAIL_USERNAME=email@website.com
GMAIL_PASSWORD=password
我将提交推送到 heroku,没有 运行 heroku 运行 rake db:setup 而只是 运行 heroku 运行 rake db:migrate .现在一切正常了:-D