哪里是存储应用程序参数的最佳场所:数据库,文件,code ...? [英] Where is the best place to store application parameters : database, file, code...?

查看:97
本文介绍了哪里是存储应用程序参数的最佳场所:数据库,文件,code ...?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个Ruby on Rails的网站,我有一个建筑的问题:我的应用程序需要一些参数,我想知道哪里来存储它们

I am developing a Ruby on Rails website and I have an "architectural" question : my application needs some parameters and I'm wondering where to store them.

在具体而言,我的应用接收的评估,然后发送一些请求。因此,请求模型必须有关于这些治疗方法属性:验证状态发送状态。例如,验证状态可以是接受拒绝的或的。 发送状态可以是发送发送的过程中错误或类似的东西。我要存储这些状态codeS参数的地方,但我不知道什么是最好的解决方案。

In concrete terms, my application receive some requests which are evaluated and then sent. So, the Request model must have attributes concerning these treatments : a validation status and a sending status. For instance, validation status can be "accepted", "rejected" or "waiting". Sending status can be "sent", "waiting", "error during sending" or stuff like that. I have to store those status codes parameters somewhere, but I don't know what is the best solution.

我可以创建为每一个模型,并将其存储在数据库中(并具有实例的活动记录模式ValidationStatus),但:不会是一咬牙过度创建用于存储这样的数据的数据库/模式?

I could create a model for each one and store them in the database (and having an active record model ValidationStatus for instance) but : wouldn't it be a bite excessive to create a database/model for storing data like that?

我也可以只使用他们在code没有储存起来,我可以将它们存储在YAML文件...

I could also just use them in the code without "storing" them, I could store them in a YAML file...

所以,一个更简单的问题:你怎么应对的RoR应用程序的参数

So, a more simpler question: how do you deal with your application parameters in RoR?

推荐答案

有许多全局配置的插件,其中大部分围绕在某些时候加载YAML文件的想法。检查此页面,的这个插件即使这样的 Railscast

There are lots of global configuration plugins, most of them revolve around the idea of loading a YAML file at some point. Check this page, this plugin and even this Railscast.

这篇关于哪里是存储应用程序参数的最佳场所:数据库,文件,code ...?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆