Rails Rails 中能把一些内容写到 properties 文件中,通过相应的 key 拿到值吗?

wl1991724 · June 11, 2015 · Last by oneapm replied at June 11, 2015 · 1537 hits

在 java 中一般 web 框架都提供了这样的功能:把一些内容以键值对的形式写入后缀为.properties 的文件中,在代码里就可以通过对应的 key 值拿到。 Rails 里也有这种机制吗?

用 yaml

Ruby 中一般使用 Yaml,如@chenge所说,不过 Ruby 读取 Java 的 properties 文件也很容易,如果你有很多现成的 Java Properties 文件读取,可以用https://github.com/jnbt/java-properties,关于 Yaml,读读这篇入门博文Yaml Tutorial

You need to Sign in before reply, if you don't have an account, please Sign up first.