routes.rb
resources :documents do
collection do
scope format: true, constaints: {format: :json} do
get :lost
end
end
end
Resultant route
lost_documents GET /documents/lost.:format documents#lost {:constaints=>{:format=>:json}, :format=>/.+/}
Result:
documents/lost.json
will answer with jsondocuments/lost
will redirect to root route