Edward Leon Jasper
Edward Leon Jasper

Reputation: 61

How to configure ActiveRecord database connection with mysql2 gem

Hey everyone Having an issue using ActiveRecord with the 'mysql2' gem. I'm using rails 4.0.4 There are these lines in my config/application.rb

# Pick the frameworks you want: 
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"

when i try to run 'rails g model user' i get

 invoke  active_record
 /Users/edjasper/.rvm/gems/ruby-2.1.1/gems/railties4.0.4/lib/rails/application/configuration.rb:110:in `database_configuration': Could not load database configuration. No such file - /Users/edjasper/Desktop/associations_challenge_8/config/database.yml (RuntimeError

any advice?

Upvotes: 1

Views: 634

Answers (1)

D.K.
D.K.

Reputation: 446

yes, you don't have database.yml in config dir smth like

development:
  adapter: mysql2
  encoding: utf8
  database: my_db_name
  username: root
  password: my_password
  host: 127.0.0.1
  port: 3306
  secure_auth: false

also you should already have database.yml.example in your config dir for sample

by the way error message already told you about it :)

No such file - /Users/edjasper/Desktop/associations_challenge_8/config/database.yml

Upvotes: 3

Related Questions