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

时间:2014-09-07 17:36:10

标签: ruby-on-rails ruby postgresql ruby-on-rails-4 heroku

我几乎已经阅读了关于部署到heroku的每个问题和文档,这不是我的第一次,但现在在我部署的一个非常奇怪的scnario我无法创建数据库:

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}

不是这个:

FactoryGirl screws up rake db:migrate process

我几乎把所有与工厂女孩有关的东西都拿出去了,一切都在spec文件中。

不是这个:

Rails 4.0.1 on Heroku, can't create database

这是我的宝石文件:

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'

在我的Heroku Logs中,这是我发现的:

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'

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

我遇到的这个问题几乎没有什么教训,但首先让我们回答,然后解释发生了什么。

简答:

尽管删除了被认为会导致rake破坏的测试,但还有其他一些事情需要删除并导致问题:

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-在seed.rb文件中发生了这种情况:

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

课程:

1-不要使用自动应用程序生成器。就我而言,我使用的是#RailsComposer。

2 Bower on Rails是一个糟糕的决定,它可以把一个非常简单的应用程序变成一个疯狂的amazin丛林