Rails 相当于全局唯一/对象 id 系统
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
指南没有语言支持。
这是一篇讨论 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