有没有办法从配置文件夹中获取rails应用程序的根URL?另外,您可以获得运行服务器的端口吗?
答案 0 :(得分:0)
在 database.yml :
中development:
adapter: mysql
encoding: utf8
database: db_development
host: https://example.com
port: XXX
username: root
password:
然后,从 config \ initializers :
调用它require "yaml"
config = YAML.load_file(Rails.root.join("config","database.yml"))[Rails.env]
config["port"] => XXX
config["host"] => https://example.com