用于在 Rails 3 中过滤资源的 SEO 友好 URL 设计
我需要在 Rails 3 中为资源实现一些 SEO 友好的排序方法。这就是我正在考虑为集合做的事情:
/things # shows all things
/things/popular # shows all things ordered by popularity
/things/a-z # shows all things ordered alphabetically
对于单个记录:
/thing/name-of-a-thing # shows ONE thing
单数/复数之间的切换是为了避免 thing-names< /em> 与排序方法名称冲突。
到目前为止,我一直在使用 resource :things
,它使用 /things
执行所有操作。我担心摆脱默认设置,因为我知道在制定这些默认设置时已经考虑了很多。因此,在我这样做之前,我想我应该寻求一些建议,以防此类事情有最佳实践。
那么,这是解决我的问题的好方法吗?我是否愿意面对未来的任何问题?有更好的方法来解决这个问题吗?
谢谢!
I need to implement some SEO-friendly sort methods for a resource in Rails 3. This is what I'm considering doing for collections:
/things # shows all things
/things/popular # shows all things ordered by popularity
/things/a-z # shows all things ordered alphabetically
And this for single records:
/thing/name-of-a-thing # shows ONE thing
The switching between singular/plural is to avoid thing-names colliding with sort-method-names.
Until now I have been using resource :things
which uses /things
for all actions. I'm apprehensive to break away from the defaults since I know a lot of thought has gone into making those defaults. So before I do, I thought I'd seek some advice in case there's a best practice for this kind of thing.
So, is this a good way to solve my problem? Am I opening myself up to any problems down the road? Are there better ways to go about this?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要通过匹配来定义所有路线。
并在所有匹配路由定义后杀死您的资源、路由或使用它。
You need define all route by match.
and kill your resources, route or use it after all match route define.