我有一个模型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
?