用于在 Rails 3 中过滤资源的 SEO 友好 URL 设计

发布于 2024-09-30 13:24:54 字数 643 浏览 0 评论 0原文

我需要在 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 技术交流群。

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

发布评论

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

评论(1

温柔戏命师 2024-10-07 13:24:54

您需要通过匹配来定义所有路线。

match '/things' => 'Things#index'
match '/things/:order' => 'Things#index'
match '/thing/:id' => 'Things#show'

并在所有匹配路由定义后杀死您的资源、路由或使用它。

You need define all route by match.

match '/things' => 'Things#index'
match '/things/:order' => 'Things#index'
match '/thing/:id' => 'Things#show'

and kill your resources, route or use it after all match route define.

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