[英]Global mutable variable in Ruby on Rails 5
I'm building a site and want to store two variables: the target and current progress for a fundraising campaign. 我正在建立一个网站,并希望存储两个变量:筹款活动的目标和当前进度。 The organization may change the target every year, and of course will need to change the current progress. 组织可能会每年更改目标,并且当然需要更改当前的进度。 I could create a model but this seems like overkill as I would never create more than one object. 我可以创建一个模型,但这似乎有点过头了,因为我永远不会创建多个对象。 Is there an easy (and standard) way to do this? 有没有简单(标准)的方法可以做到这一点?
I'm new to rails and I've looked for answers to this question but haven't found anything exceptionally helpful - I apologize if this is a common issue. 我是Rails的新手,我一直在寻找这个问题的答案,但没有发现任何特别有用的信息-如果这是一个常见问题,我深表歉意。 Other answers depict how to store site wide variables when you do not want to edit them, but here I'd like to be able to update them as often as required. 其他答案描述了当您不想编辑站点范围内的变量时如何存储它们,但是在这里,我希望能够根据需要频繁地更新它们。
This can be an answer for you: 这可以为您提供答案:
targe
and progress
. 添加两个名为targe
和progress
字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.