简体   繁体   English

Rails&Heroku:PG数据库无法创建数据库

[英]Rails & Heroku: PG db fails to create database

I have almost read every question and doc about deployment to heroku, and this is not my first time, but now in a very weird scnario when I deploy I can't create the database: 我几乎已经阅读了有关部署到heroku的所有问题和文档,这不是我的第一次,但是现在在部署时出现了一个很奇怪的问题,我无法创建数据库:

Running `rake db:create --trace` attached to terminal... up, run.8982
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:create
FATAL:  permission denied for database "postgres"
DETAIL:  User does not have CONNECT privilege.
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.2/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `initialize'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.2/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `new'
.
.
.
.
Couldn't create database for {"adapter"=>"postgresql", "host"=>"ec2-23-23-244-144.compute-1.amazonaws.com", "encoding"=>"unicode", "database"=>"d80e387p61nnl1", "pool"=>5, "template"=>"template0", "username"=>"******", "password"=>"********", "port"=>5432}

It's not this: 不是这样的:

FactoryGirl screws up rake db:migrate process FactoryGirl搞砸了耙db:迁移过程

I took out everything related to Factory girl pretty much, everything in the spec file. 我几乎删除了与Factory girl相关的所有内容,包括规范文件中的所有内容。

Not this either: 也不是这样:

Rails 4.0.1 on Heroku, can't create database Heroku上的Rails 4.0.1,无法创建数据库

this is my gemfile: 这是我的宝石文件:

source 'https://rubygems.org'
ruby '1.9.3'
gem 'rails', '4.1.2'


#Assets
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'jquery-turbolinks'
gem 'turbolinks'
gem "autoprefixer-rails"

#jQuery
gem 'magnific-popup-rails'
gem 'ckeditor'
gem 'gmaps4rails'
gem "select2-rails"
gem 'chosen-rails'
gem 'jquery-tokeninput-rails'
gem 'jquery-timepicker-rails'
gem 'easy_as_pie'
gem 'modernizr-rails'
gem "font-awesome-rails"
gem 'jquery-slimscroll-rails'
gem 'jquery-placeholder-rails'
gem 'autosize-rails'

gem 'newrelic_rpm'


#frontend
gem 'rails_12factor', group: :production
gem 'friendly_id', '~> 5.0.0' # Note: You MUST use 5.0.0 or greater for Rails 4.0+

gem 'rack-cors', :require => 'rack/cors'

gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0',          group: :doc
gem 'spring',        group: :development
gem 'bootstrap-sass'
gem 'devise'
gem 'high_voltage'
gem 'thin'

gem 'lodash-rails'


#Database
gem 'ransack'
gem 'pg'
gem 'pg_search'
gem 'simple_form'

# gem 'ng-rails-csrf'
gem 'wiselinks'

# Development Only
group :development do
  gem 'binding_of_caller', :platforms=>[:mri_19]
  gem 'rails_layout'
  gem 'meta_request'
  gem 'better_errors'
  gem 'hirb' #use Hirb.enable to enable it / text to Column
  gem 'awesome_print', :require => 'ap'
  gem 'railroady' #run this command: rake diagram:all
  gem "bullet" # it always works unless you remove the initilzer
  gem "reek" # run this : reek .
  gem 'brakeman', :require => false # run this : brakeman [appPath] -o output_file
  gem 'traceroute' # to check unUsed and Unreachable routes >  rake traceroute
  gem 'quiet_assets' #takes away the Asset messages in the Log
  gem 'annotate', ">=2.6.0"
  gem "letter_opener", :group => :development
  gem 'rails_apps_pages'
end


group :development, :test do
  gem 'rspec-rails'
end


group :test do
  gem 'capybara'
  gem 'database_cleaner'
  gem 'launchy'
  gem 'selenium-webdriver'
end

gem 'ffaker'
gem 'populator'

gem 'activeadmin', github: 'gregbell/active_admin'
# gem "meta_search",    '>= 1.1.0.pre'
#rails Legacy Gems
gem 'protected_attributes'
gem 'rails-observers'
gem 'actionpack-page_caching'
gem 'actionpack-action_caching'


#Images:
gem 'carrierwave'
gem 'rmagick', :require => false




gem 'kaminari'


# gem "bower-rails", "~> 0.8.3"
# gem 'react-rails', '~> 0.10.0.0'
# gem 'react-rails', '~> 1.0.0.pre', github: 'reactjs/react-rails'
# gem "therubyracer", :platforms => :ruby
# gem "therubyrhino", :platforms => :jruby

gem 'activerecord-reputation-system'
gem 'acts-as-taggable-on'
gem 'markable'

gem 'country_select', github: 'stefanpenner/country_select'
gem 'rails4-autocomplete'

# gem 'linkedin' hasie 3.3.0 error
#messaging
gem 'mailboxer'

IN my Heroku Logs, this what I found: 在我的Heroku日志中,这是我发现的:

Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
2014-09-07T17:20:38.089695+00:00 app[web.1]: => Ctrl-C to shutdown server
2014-09-07T17:20:38.089697+00:00 app[web.1]: Exiting
2014-09-07T17:20:38.357403+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/activesupport-4.1.2/lib/active_support/dependencies.rb:247:in `require': No such file to load -- mini_magick (LoadError)
2014-09-07T17:20:38.357406+00:00 app[web.1]:    from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-4.1.2/lib/active_support/dependencies.rb:247:in `block in require'

any help would be veryyy very much appreciated. 任何帮助将不胜感激。

There are few lessons to be learnt from this problem that I came across, but first let's answer and then explain what was going on. 从我遇到的这个问题中学到的经验教训很少,但首先让我们回答,然后解释发生了什么。

Short answer: 简短答案:

Despite removing the tests that was considered to cause the rake to break, there were other things left out that needed to be removed and it was causing problems: 尽管删除了被认为导致耙子损坏的测试,但是还有其他一些需要删除的东西,这导致了问题:

1- In the application.rb this was happening: 1-在application.rb这种情况正在发生:

 config.generators do |g|
g.test_framework :rspec,
fixtures: true,
view_specs: false,
helper_specs: false,
routing_specs: false,
controller_specs: false,
request_specs: false
g.fixture_replacement :factory_girl, dir: "spec/factories"
end

2- In seed.rb file this was happening: 2-在seed.rb文件中,这种情况正在发生:

# user = CreateAdminService.new.call
# puts 'CREATED ADMIN USER: ' << user.email

The lesson: 课程:

1- Don't use auto app generators. 1-不要使用自动应用生成器。 In my case I was using #RailsComposer. 就我而言,我使用的是#RailsComposer。

2- Bower on Rails is a bad decision, it can turn a very simple app to a crazy amazin jungle 2-Bower on Rails是一个错误的决定,它可以将一个非常简单的应用程序变成疯狂的亚马逊丛林

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM