最佳的Rails永久链接 [英] Best Permalinking for Rails

查看:79
本文介绍了最佳的Rails永久链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您认为在Rails中动态创建SEO友好URL的最佳方法是什么?

What do you think is the best way to create SEO friendly URLs (dynamically) in Rails?

推荐答案

覆盖模型类中的to_param方法,以便将默认数字ID替换为有意义的字符串.例如,这个问题在URL中使用了 best-permalinking-for-rails .

Override the to_param method in your model classes so that the default numeric ID is replaced with a meaningful string. For example, this very question uses best-permalinking-for-rails in the URL.

Ryan Bates对此主题有铁路广播.

Ryan Bates has a Railscast on this topic.

这篇关于最佳的Rails永久链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆