2010-11-03 39 views
1

我需要实现的Rails 3对资源的一些搜索引擎友好的排序方法,这是我考虑这样做对集合:SEO友好的URL设计用于过滤Rails中的资源3

/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 

单数/复数之间的切换是为了避免东西,名字排序方法-名碰撞。

到现在为止,我一直在使用resource :things,它使用/things进行所有操作。我担心要脱离默认设置,因为我知道有很多想法已经进入了默认设置。所以在我做之前,我想我会寻求一些建议,以防这种事情有最佳做法。

那么,这是解决我的问题的好方法吗?我是否可以解决任何问题?有更好的方法去做这件事吗?

谢谢!

回答

0

您需要按比赛定义所有路线。

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

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

+0

谢谢,但这不是问题。我明白如何实现这一点。我问是否这是一个好的网址设计和/或有什么替代品/最佳做法存在这个问题。 – Marcus 2010-11-03 07:50:01