带点的漂亮网址(Friendly_id gem)
许多解决方案适用于 Rails 2,但没有适用于 Rails 3.1,因为地图对象已被删除。
最新的rails中这个问题有解决方案吗?
Many solutions are available for rails 2 but none for rails 3.1 because the map object has been removed.
Any solution for this problem in the latest rails?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最近不得不在一个项目中这样做。幸运的是,在每个模型的基础上重写 slug 生成方法很简单。
请参考
https://github.com/诺曼/Friendly_id/blob/master/lib/Friendly_id/slugged.rb#L113-116
和
https://github.com/norman/friend_id/blob /master/lib/Friendly_id/slugged.rb#L227-231
您应该能够在模型上定义它:
希望这会有所帮助。
注意:此方法在FriendlyId 3.x中也可用。它非常适合定义用于生成 slug 字符串的自定义正则表达式。
I have had to do this recently on a project. Luckily, it's simple to override the slug-generating method on a per-model basis.
please refer to
https://github.com/norman/friendly_id/blob/master/lib/friendly_id/slugged.rb#L113-116
and
https://github.com/norman/friendly_id/blob/master/lib/friendly_id/slugged.rb#L227-231
you should be able to define this on the model:
Hope this helps.
Note: This method is available in FriendlyId 3.x as well. It's great for defining a custom regex for generating slug strings.