문제

What is the best practice for storing non-tabular settings (configured by the end-user) for the application?

I know it is possible by creating a model and using it, but creating a one-row-table in the database seems a little wasteful to me.

도움이 되었습니까?

해결책

Convert the data to YAML, and write it to a configuration file.

require "yaml"

File.write(path_to_configuration_file, YAML.dump(obj)) # write

obj = YAML.load_file(path_to_configuration_file) # read
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top