我想在蒙戈posts/:title
更換網址posts/:id
。有沒有辦法做到這一點。我試着在模型SEO友好的URL爲蒙戈
class Post
include Mongoid::Document
include Mongoid::Timestamps
field :title
key :title
end
使用key
但我的網址不會改變,我在這裏失蹤某物還我收到此錯誤Document not found for class Post with id(s)
?
[Mongoid ::彈頭](https://github.com/papercavalier/mongoid-slug)也是一個非常不錯的選擇,有一些更多的功能。 – theTRON