Rails 相当于全局唯一/对象 id 系统

发布于 2024-12-01 20:00:31 字数 783 浏览 0 评论 0原文

我有一个 php 应用程序,并且需要考虑将其移植到 Rails。

尚不清楚是否存在与特定部件等效的预构建件。它有一个带有唯一对象识别系统的表。并非所有对象都参与该系统,只有被认为“有趣”的对象才参与该系统。

一个简化的例子:

user - uses system
id user_name
1   joe
2   frank

image - uses system
id url
1   /img/123.jpg
2   /img/234.jpg

comment - uses system
id comment 
1  what are you doing?
2  this is great

global_identification
id  object_type object_id
1   user        1
2   comment     1
3   image       1
4   user        2
5   image       2
6   comment     2

globals_lists
1   list_id     global_id
2   1           3            
3   1           6

这简化了很多元素,特别是对于列表创建来说,只需要一个 global_identifiter 而不是一个对象和一个 id。它是一个 php Web 应用程序,因此本质上是单线程的。

这本质上是手工卷制的,我很好奇是否有类似的 Rails 等价物?另外,在与另一位开发人员交谈时,我很好奇是否有一个名称 - 它有点像一个半生不熟的 GUID 系统?

I have a php app and there there is some consideration about porting it to Rails.

One piece where it is unclear whether there is a prebuilt equivalent to a specific part. It has a table with a unique identifying system for objects. Not ALL objects participate in this system, just objects that are considered 'interesting'.

A simplified example:

user - uses system
id user_name
1   joe
2   frank

image - uses system
id url
1   /img/123.jpg
2   /img/234.jpg

comment - uses system
id comment 
1  what are you doing?
2  this is great

global_identification
id  object_type object_id
1   user        1
2   comment     1
3   image       1
4   user        2
5   image       2
6   comment     2

globals_lists
1   list_id     global_id
2   1           3            
3   1           6

This has simplified a lot of elements esp for list creations having only to have a global_identifiter rather than an object and an id. It's a php web app so essentially single-threaded.

This is essentially hand-rolled and am curious whether there is a rails equivalent of something like this? Also, talking with another developer, I was curious whether there is a name for this - it's kinda like a half-baked GUID system?

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

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

发布评论

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

评论(1

谈情不如逗狗 2024-12-08 20:00:31

指南没有语言支持。

这是一篇讨论 guid 的文章: http://amthekkel.blogspot.com/2009/02/ruby-on-rails-how-to-use-guid-for-use.html

There is no in-language support for guid.

Here is a an articles that talks about guid: http://amthekkel.blogspot.com/2009/02/ruby-on-rails-how-to-use-guid-for-use.html

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