1
我有一個模型foo
。定義具有成員端點的資源端點
在我config/routes.rb
我有:
resources :foo do
member do
post 'approve'
post 'delete'
end
get 'another_action'
end
如果我做一個jQuery $.get("/foo/another_action")
電話,我得到下面的輸出:
ActiveRecord::RecordNotFound (Couldn't find Foo with id=another_action):
app/controllers/foo_controller.rb:20:in `show'
我也想這樣做:
resources :foo do
member do
post 'approve'
post 'delete'
end
end
resource :foo do
get 'another_action'
end
如何指定/foo/another_action
的路線,以便控制呃將其視爲資源級端點而不是id
?
謝謝!我已經瀏覽了路由指南,但是我設法錯過了'collection',並且在我所有的Google搜索中,我都沒有想到要使用該關鍵字。一旦SO會讓我接受這個答案。 – asfallows