RoR,我应该如何建模?

发布于 2024-12-15 02:16:07 字数 440 浏览 0 评论 0原文

我之前问过这个问题,但我很模糊,很多人建议,由于我刚刚开始使用 Ruby 和 RoR,也许我专注于“Hello, World!”会更好。第一的。我很感激答案是诚实的,但这是我项目的一部分,所以我必须完成它。我希望把事情做好,这样以后的问题就会少一些。

我想做的是:

我正在制作一个网络应用程序,基本上允许用户创建一个 桌子。他们为表命名并添加多个列(字段)。然后他们 添加 条目(行),就像典型的表格一样。

例如,用户可以创建一个名为“High-Scores”的表。然后 添加字段“姓名”、“积分”、“成就”。这 3 个将是 列。然后他们可以添加一个条目,例如“John”、“123”、 “金子”。

我如何使用 Active-Records Base 子类对此进行建模?基本上,从我所掌握的情况来看 到目前为止,从教程中了解到,模型具有预定的字段。现在, 我有动态字段。

感谢您的帮助。

I asked this question earlier but I was very vague and a lot of people suggested that since I am just starting with Ruby and RoR, maybe it's better if I focus on "Hello, World!" first. I appreciate that the answers were honest, but this is part of my project so I have to get it done. And I want to get it done right so there's less problems later on.

What I am trying to do is this:

I am making a web application that basically allows user to create a
table. They name the table and add multiple columns (fields). Then they
add
entries (rows), just like a typical table.

So for example, the user can create a table called "High-Scores". Then
add fields "Name", "Points", "Achievements". These 3 will be the
columns. Then they can add an entry, so for example, "John", "123",
"Gold".

How would I model this with a Active-Records Base subclass? Basically, from what I have
learned from tutorial so far, the models have predetermined fields. Now,
I have dynamic fields.

Thanks for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

昵称有卵用 2024-12-22 02:16:07

这取决于您的要求。如果这不是您的应用程序的特定目标,您实际上不应该为每个用户创建新表。如果您只想让用户在网页上的“表”中输入数据,您可以将表建模为四个表,一个用于 TableName,一个用于 ColumnName,一个用于 ColumnName对于每个 TableEntry 以及名为 EntryValue 的 TableEntry 中的每一列。

为此创建视图会很棘手,但这是可能的。

It depends on your requirements. You shouldnt really create new tables for each user if thats not the specific goal of your application. If you just want the user to enter data in a "table" on your webpage you can model a table in four tables one for the TableName, one for the ColumnName, one for each TableEntry and one for each column in a TableEntry called EntryValue.

It will be tricky to create the view for that but its possible.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文