嘿大家在使用ActiveRecord时遇到问题' mysql2'宝石。我使用的是rails 4.0.4我的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"
当我尝试运行' rails g model user'我得到
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
任何建议?
答案 0 :(得分:3)
是的,你在config dir中没有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
你的config dir中也应该有sample.yml.example样本
通过错误信息告诉你的方式:)
No such file - /Users/edjasper/Desktop/associations_challenge_8/config/database.yml