创造性地使用标签

发布于 2025-01-05 06:45:18 字数 408 浏览 1 评论 0原文

这个问题是关于 acts_as_taggable_on 但我相信它通常适用于标记。

使用标签来存储有关用户活动的小细节(例如他们的交互历史记录)是否合适?

例如:我们的用户最后希望关闭演示面板,因此我们将其存储为名为 home_demo_close 的标签,然后在下一个页面加载时可以轻松搜索该标签。

另一种方法是每当我们想要存储新的交互点时就向数据库添加一列。对我来说,这似乎有点矫枉过正——笨重、需要实施大量工作,而且考虑到前端设计变化的速度,它过于“固定”。

您认为继续此操作的最佳方法是什么 - 将标签用于“创意”目的是否存在我没​​有考虑的设计缺陷?

This question is about acts_as_taggable_on but I believe it applies to tagging in general.

Is it appropriate to use tags to store little details about a user's activity, such as their interaction history?

For example: our user last wanted the demo panel closed, so we store this as a tag called home_demo_closed, which is then easily searchable on the next page load.

The alternative is adding a column to the database every time there's a new point of interaction we want to store. This seems like overkill to me - clunky, lots of work to implement, and too 'fixed' given how rapidly the front-end design can change.

What do you think is the best way to proceed with this - is there a design flaw with using tags for 'creative' purposes like this that I'm not considering?

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

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

发布评论

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

评论(1

久而酒知 2025-01-12 06:45:18

从哲学上讲,在这里使用“标签”似乎是错误的——标签是一种使用一个或多个可搜索或可分类术语对数据对象进行索引的方法。话虽如此,底层技术(一侧是数据对象,另一侧是原子数据元素的多对多关系)是一种完全可行的方法。从代码可读性的角度来看,我可能会继续创建一个新的表 preferences 和一个连接表 user_preference_settings

这就像一个关于物理学生的老笑话,他被问到如何使用气压计来了解建筑物的高度。他给出的答案是“把气压计从楼顶掉下来,计算一下落到地面需要多长时间”。聪明、有效,但肯定不是其他人期望找到的答案。 :)

Philosophically, it seems like a "tag" would be the wrong thing to use here - a tag is a way of indexing a data object with one or more searchable or categorizable terms. That having been said, the underlying technology (a many-to-many relationship with data objects on one side and atomic data elements on the other) is a perfectly viable approach. I'd probably go ahead and create a fresh table preferences and a join table user_preference_settings, just from a code readability perspective.

It's like the old joke about the physics student who was asked how he would learn the height of a building using a barometer. The answer he gave was "Drop the barometer off the top of the building, and time how long it takes to hit the ground." Clever, effective, but certainly not the answer someone else would expect to find. :)

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