当前位置: 动力学知识库 > 问答 > 编程问答 >

Replacing value of key in settings.yml using rails app

问题描述:

I have a key in rails application /my_app/config/settings.yml

age: 25

I want to replace value of age from 25 to whatever user enters using ruby code.

How can i do it. Is it necessary to load the file first before writing the value?

网友答案:

Open the file in write mode

Read and parse the yml content from your file.

Replace the value

Write yml values into original file or a new file.

Done.

网友答案:

Rails provides internationalization support for static content , has_translations complements that and provides internationalization support for dynamic contents.

The gem can be find from here.

分享给朋友:
您可能感兴趣的文章:
随机阅读: