How do I access the contents of database.yml inside an ActiveRecord migration? Specifically, I need the value of the database key for the database 开发者_StackOverflow社区being migrated.
db = YAML.load_file("#{RAILS_ROOT}/config/database.yml")[RAILS_ENV]['database']
Try ActiveRecord::Base.configurations
加载中,请稍侯......
精彩评论