我在使用導軌路線時有點困惑。我需要一些關於自定義我的網址的建議。定製導軌路由網址
這是我當前的URL
http://localhost:3000/posts/product/41?product_id=2
和
http://localhost:3000/posts/product/41?model_id=24&product_id=2
這是我的鏈接
<%= link_to product_model.name, controller: :posts,action: :product,product_id: params[:product_id],model_id: product_model.id
按道理產品應該首先在URL。但爲什麼模型首先在這裏。
,我需要我的網址是這樣的
http://localhost:3000/posts/product/41/mobile
和
http://localhost:3000/posts/product/41/mobile/nokia
由於我不熟悉的軌道路線,我沒有寫任何特殊的編碼在我的路線
以下是存在的簡單路線
resources :posts
可以使用友好-ID的寶石。 –
@AmitSharma是的,我只使用friendly-id,但我可以像上面那樣工作 – overflow
@Seting,在您當前的URL中,「41」代表什麼? –