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

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

问题描述

我在开发一个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.

具体来说,我的应用程序接收一些请求,然后评估然后发送。因此,请求模型必须具有有关这些处理的属性:验证状态发送状态。例如,验证状态可以接受拒绝等待发送状态可能是发送等待我必须将这些状态代码参数存储在某个地方,但我不知道什么是最好的解决方案。

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?

I也可以只在代码中使用它们而不存储它们,我可以将它们存储在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.

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

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