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

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

问题描述

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

具体来说,我的应用程序收到一些请求,这些请求经过评估然后发送.因此,请求模型必须具有与这些处理相关的属性:验证状态发送状态.例如,验证状态可以是accepted"、rejected"或waiting".发送状态可以是发送"、等待"、发送过程中出错"或类似的东西.我必须将这些状态代码参数存储在某处,但我不知道最佳解决方案是什么.

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?

我也可以只在代码中使用它们而不存储"它们,我可以将它们存储在 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天全站免登陆