如何正確使用 url name helper
2012-03-18 18:05:23 +0800 由 tonytonyjan
在 Ruby on Rails 節點 中發起
最後由 tonytonyjan 於2012-03-20 02:00:10 +0800回應
, 286次閱讀
假設在我的 routes.rb 中有一筆如下:
match "photo/:type/:id", :action=>"do_it", :via=>:put
do_it_photo_path(:type=>0, :id=>1)
會產生 photo/do_id?type=0&id=1
而不是 photo/do_id/0/1
。
我該如何使用 do_it_photo_path
helper,才會正常輸出成 photo/do_id/0/1
呢?
截至 2012-03-20 02:00:10 +0800,共收到 2 條回應
xdite
1樓, 於2012-03-19 02:17:36 +0800回應
為何你不 follow restful ?
tonytonyjan
2樓, 於2012-03-20 02:00:10 +0800回應
因為我對 Polymorphic Associations 要如何做 rest 不甚瞭解,加上在 rails guide 找不到相關的資料,所以特來此請教前輩。