had a working rails app and get a weird bug - rails wants to use postgresql even tho mysql adapter is specified. Everything worked 100% fine til I worked on another project that uses postgresql.
But still, this doesn't make ANY sense. I've been on this for hours. Maybe I'm just blind, I'd appreciate the help big times.
error msg for local testing:
bash-3.2$ rails s
=> Booting WEBrick
=> Rails 4.0.3 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/connection_adapters/connection_specification.rb:58:in `rescue in resolve_hash_connection': Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile. (Gem::LoadError)
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/connection_adapters/connection_specification.rb:55:in `resolve_hash_connection'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/connection_adapters/connection_specification.rb:46:in `resolve_string_connection'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/connection_adapters/connection_specification.rb:32:in `spec'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/connection_handling.rb:39:in `establish_connection'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/railtie.rb:176:in `block (2 levels) in <class:Railtie>'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:27:in `each'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:27:in `on_load'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/railtie.rb:174:in `block in <class:Railtie>'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/initializable.rb:30:in `run'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/mg/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
from /Users/mg/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
from /Users/mg/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
from /Users/mg/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
from /Users/mg/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:180:in `each'
from /Users/mg/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
from /Users/mg/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/application.rb:215:in `initialize!'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/mg/Dropbox/delightotet/delighto/config/environment.rb:16:in `<top (required)>'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/polyglot-0.3.4/lib/polyglot.rb:65:in `require'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/polyglot-0.3.4/lib/polyglot.rb:65:in `require'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `block in require'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:214:in `load_dependency'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `require'
from /Users/mg/Dropbox/delightotet/delighto/config.ru:3:in `block in <main>'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
from /Users/mg/Dropbox/delightotet/delighto/config.ru:in `new'
from /Users/mg/Dropbox/delightotet/delighto/config.ru:in `<main>'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/commands/server.rb:48:in `app'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/commands/server.rb:75:in `start'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/commands.rb:76:in `block in <top (required)>'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/commands.rb:71:in `tap'
from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/commands.rb:71:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
database.yml
development:
adapter: mysql2
database: xxx
user: xxx
password:
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: mysql2
database: xxx
user: xxx
password:
production:
adapter: mysql2
database: xxx
user: xxx
password: xxx
My Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.3'
gem 'mysql2'
gem 'sprockets', '2.11.0'
gem 'mail_form'
# Use SCSS for stylesheets
gem 'sass-rails'
# DROPBOX
gem 'dropbox-sdk'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails'
#mailchimp
gem 'gibbon'
gem 'mandrill-api'
gem 'net-ssh', '~>2.7.0'
#devise auth
gem 'devise'
# SUPPORT PROCESSES
gem "zendesk_api"
# AFTER SALES PROCESSES
# SHIPPING SOLUTIONS
gem 'dhl-intraship'
# GENERATE PDF INVOICE
gem 'spree_print_invoice' , :git => 'https://github.com/mgreschke/spree_print_invoice.git', branch:'2-2-stable'
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'gritter'
gem 'friendly_id'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
#password encryption
gem "bcrypt-ruby", :require => "bcrypt"
gem 'money', '6.0.1'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
gem "capistrano", "2.14.2", group: :development
gem "mime-types", "1.25"
gem "rake", "10.3.1"
#meta tags
gem 'meta-tags'
# Use debugger
# gem 'debugger', group: [:development, :test]
gem 'spree', '2.2.1'
gem 'spree_gateway', :git => 'https://github.com/spree/spree_gateway.git', :branch => '2-2-stable'
gem 'spree_i18n', :github => 'spree/spree_i18n', :branch => '2-2-stable'
If you have an environment variable called DATABASE_URL
then rails will use that.
This is documented in the rails guides and it particular states that rails will try to merge database.yml with the environment variable with the environment variable taking precedence.
I think that as part of one of these other postgres projects you mentioned you have set this environment variable. If you run env
at your shell prompt then you should see a list of environment variables. If DATABASE_URL
is there and persists after you open/close a terminal window then you are probably setting it in one of your shell startup files (for example for bash try .bashrc, .bash_profile)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다