2014-10-31 55 views
1

嗨大家在使用ActiveRecord和'mysql2'gem時遇到問題。我使用的鐵軌4.0.4有在我的配置,這些線/ application.rb中如何使用mysql2 gem配置ActiveRecord數據庫連接

# 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" 

當我嘗試運行「軌道G型用戶」我得到

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 

什麼建議嗎?

回答

3

是的,你沒有的database.yml在配置目錄 水木清華像

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

還應該的方式已經在你的配置目錄database.yml.example樣品

錯誤信息已經告訴過你:)

No such file - /Users/edjasper/Desktop/associations_challenge_8/config/database.yml 
相關問題