1

please help me to resolve my problem I've read all topics here but still cannot understand what's going on

so I run git push heroku master

here is what I get

rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)

after that I updated my Gemfile, here it is

ruby '1.9.3'
source 'https://rubygems.org'

gem 'rails', '3.2.13'
gem 'mysql2'
gem 'pg'

group :assets do
  gem 'sass-rails',  '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
  gem 'therubyracer', :platform => :ruby
end

gem 'less-rails', '~> 2.2.6'
gem 'sass-rails', '~> 3.2.3'
gem 'twitter-bootstrap-rails', '2.2.4'

gem 'jquery-rails'
gem 'devise'
gem 'haml', '~> 4.0.0'
gem 'haml-rails'
gem 'cancan'
gem 'rails-i18n', '~> 3.0.0.pre'
gem 'i18n-js', :github => 'fnando/i18n-js'
gem 'obscenity'
gem 'thin'
gem 'will_paginate-bootstrap'
gem 'nifty-generators', :group => :development
gem 'rails_12factor'
gem 'mocha', :group => :test

after that bundle install show an error

and here is config/database.yml

production:
  adapter: mysql2
  host: 127.0.0.1
  encoding: utf8
  reconnect: false
  database: xxx_production
  pool: 5
  username: root
  password: "xxxx"
  socket: /var/run/mysqld/mysqld.sock
development:
  adapter: mysql2
  host: localhost
  encoding: utf8
  reconnect: false
  database: xxx_development
  pool: 5
  username: root
  password: "xxxx"
  socket: /var/run/mysqld/mysqld.sock

test:
  adapter: mysql2
  host: localhost
  encoding: utf8
  reconnect: false
  database: xxx_test
  pool: 5
  username: root
  password: "xxxx"
  socket: /var/run/mysqld/mysqld.sock

Do you guys have any ideas?

Thanks in advance!

Maria
  • 79
  • 7

2 Answers2

1

Heroku runs on the PostgreSQL db the easiest.

You have both pg and mysql2 installed and are using mysql2 for production db.

It would be a lot easier to use the PG database in production for Heroku.

To do this, first clear the production section of your database.yml Then, in your Gemfile, put the pg gem in a production section like so:

group :production do
  gem "pg"
end

If you really want to use mysql then check out these articles

https://devcenter.heroku.com/articles/heroku-mysql

https://addons.heroku.com/cleardb

Justin
  • 4,922
  • 2
  • 27
  • 69
  • Thank you! I removed gem "mysql2", and updated database.yml accordingly, than ran `bundle install`(successfully) and then `rake db:migrate` and got this `rake aborted! Please install the postgresql adapter: gem install activerecord-postgresql-adapter (can't activate pg (~> 0.11), already activated pg-0.9.0. Make sure all dependencies are added to Gemfile.)` – Maria Mar 11 '14 at 19:37
  • ah, I do have an idea – that's may be because of socket. How to update socket? – Maria Mar 11 '14 at 19:44
  • Well you didn't have to remove mysql, because you are using that for your development and test database. I would have grouped that gem in `:test, :development` with pg gem in `:production`. It's a little more complicated getting a PostgreSQL database working in development environment (http://railscasts.com/episodes/342-migrating-to-postgresql). But to clear the trouble for the pg gem, maybe running `gem update pg` will update it. – Justin Mar 11 '14 at 20:35
0

I was having almost exactly the same issue, posted my solution to this question, which has similar symptoms to what you described here.

Essentially: Did you update your git repository before doing the git push heroku master command?

I assume you included the pg gem because you felt you had to use the PostgreSQL stuff with heroku and so am not addressing the mysql declarations in your production section as they would be stripped anyway.

(I haven't the reputation to put this in a comment)

Community
  • 1
  • 1
Ben Davis
  • 41
  • 5