everyone. I am trying to set up rails 3 project with mysql as database on macOS X. However, I receive the next error:
/usr/local/bundle/gems/activerecord-3.2.22.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:68:in connection_url_to_hash': undefined method `sub' for nil:NilClass (NoMethodError)
config/database.yml
default: &default
adapter: mysql2
pool: 5
encoding: utf8
min_messages: warning
timeout: 5000
username: root
password:
database: heart_development
host: localhost
Can anyone suggest how to solve this problem?
From the database.yml which you have shared and the logs posted it seems like it is unable to find the path where the database is located.
Change the database.yml to
default: &default
adapter: mysql2
pool: 5
encoding: utf8
min_messages: warning
timeout: 5000
username: root
password:
database: heart_development
host: localhost
Specified host for which the database has to connect to.
I commented environmental variable DATABASE_URL
in my .env
file. Also I configured my database.yml
in the next way:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: heart_development
pool: 5
username: root
password:
host: localhost
port: 3306
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: heart_test
pool: 5
username: root
password:
host: localhost
port: 3306
production:
adapter: mysql2
encoding: utf8cm
reconnect: false
database: heart_production
pool: 5
username: root
password:
host: localhost
port: 3306
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.