开发者

Read database.yml from inside ActiveRecord migration

开发者 https://www.devze.com 2023-01-12 22:50 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消