问题描述:

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.

相关阅读:
Top