ActiveResource and collections

About RESTful collections, what do people think about "the correct" way of returning empty collections with Rails+ActiveResource?

Suppose I hit up a URI for a collection and the collection is empty. Should we return 404 or an empty container? I'm currently returning 404 and this causes the ActiveResource client application to raise ActiveResource::ResourceNotFound even on a find(:all), which is different than how ActiveRecord behaves in the analogous scenario.

(Appologies if this turns out to be a double-post... my first attempt does not appear to have gone through).

About RESTful collections, what do people think about "the correct" way of returning empty collections with Rails+ActiveResource?

Suppose I hit up a URI for a collection and the collection is empty. Should we return 404 or an empty container? I'm currently returning 404 and this causes the ActiveResource client application to raise ActiveResource::ResourceNotFound even on a find(:all), which is different than how ActiveRecord behaves in the analogous scenario.

I think I’d lean towards returning an empty list. As I see it, a 404 should be issued if you don’t recognise the concept of that resource, or if someone requests a specific resource that we don’t have, but if the collection exists and is empty, we should say so.

In other words, if you have the resource types books and authors but not illustrators and the authors collection is empty I’d expect:

GET /books – a list of books

GET /authors – an empty list

GET /authors/1 – 404

GET /illustrators – 404

James.

I agree with this rationale.

I submitted ticket#6291 [1] a couple of days ago which fixed ARes in the single-element-in-collection edge case, and I just uploaded a new diff which also fixes ARes find_every when the collection is empty.

[1] http://dev.rubyonrails.org/ticket/6291