我有下面的路由塊,並且想要爲charges/:id
添加GET
處理程序。成員塊上的訪問根路徑
resources :charges, only: [:index, :create] do
member do
post :capture
end
end
我嘗試添加root :index
到member
塊,但沒有工作..
我有下面的路由塊,並且想要爲charges/:id
添加GET
處理程序。成員塊上的訪問根路徑
resources :charges, only: [:index, :create] do
member do
post :capture
end
end
我嘗試添加root :index
到member
塊,但沒有工作..
什麼你想在這裏是這裏提到的show動作:
guides.rubyonrails。組織/ routing.html#CRUD動詞-和行動
在routes.rb中試試這個:
resources :charges, only: [:show, :index, :create] do
member do
post :capture
end
end
沒有意識到':show'方法實際上是在'member's上運行的..感謝鏈接到文檔! – FloatingRock
高興地幫助:) –
你的意思是展示方法嗎?喜歡的資源:收費,只:[:顯示,:索引,:創建]做..... –
我想要一個GET處理程序的個人'收費'與':ID' – FloatingRock
http://guides.rubyonrails。 org/routing.html#crud-verbs-and-actions 正如你在這裏看到的,:show方法給你一個GET請求 –