給出一個像Thread(id,uuid)uuid這樣的模型,它是一個唯一生成的標識符。我想改變缺省路由:routes.rb,如何爲路徑設置不同的主鍵?
edit_thread GET /threads/:id/edit(.:format) {:action=>"edit", :controller=>"threads"}
thread GET /threads/:id(.:format) {:action=>"show", :controller=>"threads"}
PUT /threads/:id(.:format) {:action=>"update", :controller=>"threads"}
要不要使用:ID,但用戶:UUID ---這是如何在軌道/ routes.rb中成爲可能?
感謝
謝謝,但我沒有得到的是如何改變它在我的路線?我需要做一堆比賽嗎?我想軌道會有一個更優雅的設置... thxs – AnApprentice
@AnApprentice:對不起,我沒有意識到你的意思是你想改變資源路線中的'id'參數。我不認爲這是可能的(你在這裏突破軌道公約)。之前有人問過類似的問題:(http://stackoverflow.com/questions/810385/how-to-rename-the-default-identifier-param-id-in-rails-map-resources)。 – cam