我正在使用 Rocket_Pants gem 为我现有的 Rails 应用程序提供 API 访问。我的路线中有以下内容:
# HTTP routing
resources :posts do
collection do
get 'search'
end
end
# API routing
api :version => 1 do
resources :posts, :only => [:index, :show]
resources :posts do
collection do
get 'search'
end
end
end
我的 json API 请求posts/
和post/:id works
. 但是,json API 查询localhost:3000/1/posts/search?query=my_query
不会。
(注意:http 请求localhost:3000/posts/search?query=my_query
有效)。
我应该如何解决这个问题?