简体   繁体   English

我应该如何在Rails应用程序的数据库中使用百分比值?

[英]How Should I use percent values in my database for a Rails app?

I am very new to Ruby on Rails, and I was looking for a way to include decimals in my database. 我是Ruby on Rails的新手,我一直在寻找在数据库中包含小数的方法。 For example, if I wanted to take a total score and and multiply it by a certain rate to get a new score. 例如,如果我想获得总分并将其乘以一定比率以获得新分。 Would I use rails g model student name:string,score:integer,rate:decimal ? 我会使用rails g model学生名称:string,score:integer,rate:decimal吗?

Yes - you can use that to generate your model. 是的-您可以使用它来生成模型。 But, could you explain in more detail what you are trying to do? 但是,您能否更详细地说明您要做什么? The first statement "was looking for a way to include decimals in my database." 第一条语句“正在寻找一种在数据库中包含小数的方法。” - seems orthogonal to the "would i use..." question. -似乎与“我会使用...”问题正交。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM