缓存Friendly_id插件
Class Product < ActiveRecord::Base
has_friendly_id :name, :use_slug => true
end
在“产品”表中存储段的最有效方法是什么? 我有复杂的查找查询,并且与“slugs”表的连接给我带来了性能瓶颈。
Class Product < ActiveRecord::Base
has_friendly_id :name, :use_slug => true
end
What is the most efficient method to store the slugs within the 'products' table.
I have complex find queries, and the joins with the 'slugs' table give me performance bottlenecks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,我知道这是一个老问题,但只是想注意一下,对于其他可能偶然发现这个问题的人:
问题中的代码片段来自FriendlyId 3.x,在这种情况下,您将在表中添加一列(称为除了
slug
之外的任何内容...我更喜欢使用cached_slug
) 作为字符串并更新模型以显示从Friendly_id 4.x 开始,您只需添加一个
slug
列作为string
添加到表中,并使用新语法:例如:
有一大堆选项和方法可以充分利用Friendly_id,包括历史记录(避免 404s) 等...
更多信息: http://rubydoc.info/github/norman /Friendly_id/master/frames
Ok, I know this is an old question, but just wanted to note, for others that may stumble across this:
The code snippet in the question is from FriendlyId 3.x in which case you would add a column to your table (call it anything except for
slug
... I prefer to usecached_slug
) as a string and update the model to showAs of friendly_id 4.x, you simply just add a
slug
column as astring
to the table, and use the new syntax:eg:
There are a whole bunch of options and ways to get the most out of friendly_id including historical records (to avoid 404s) etc ...
More information: http://rubydoc.info/github/norman/friendly_id/master/frames
Friendly_id 现在有内置的 slug 缓存。
Friendly_id now has built-in slug caching.