2015-01-06 32 views
1

我有下面的路由塊,並且想要爲charges/:id添加GET處理程序。成員塊上的訪問根路徑

resources :charges, only: [:index, :create] do 
    member do 
    post :capture 
    end 
end 

我嘗試添加root :indexmember塊,但沒有工作..

+0

你的意思是展示方法嗎?喜歡的資源:收費,只:[:顯示,:索引,:創建]做..... –

+0

我想要一個GET處理程序的個人'收費'與':ID' – FloatingRock

+1

http://guides.rubyonrails。 org/routing.html#crud-verbs-and-actions 正如你在這裏看到的,:show方法給你一個GET請求 –

回答

3

什麼你想在這裏是這裏提到的show動作:

guides.rubyonrails。組織/ routing.html#CRUD動詞-和行動

在routes.rb中試試這個:

resources :charges, only: [:show, :index, :create] do 
    member do 
    post :capture 
    end 
end 
+0

沒有意識到':show'方法實際上是在'member's上運行的..感謝鏈接到文檔! – FloatingRock

+0

高興地幫助:) –