What's the most RESTful approach here?

Hi all

I'm working on an app at the moment and I'm trying to think of the
most RESTful way of implementing one of the key parts of the site.

Some advice on the best approach would really help.

To give you an example, I have one model but it's split into three
different categories: lost, found, broken.

Users can browse them by category but never all together.

My initial reaction is simply to have one index and determine the
category by parameter:

www.mypage.com/items?category=lost

This seems like the DRYest option.

This would mean one of the categories should be the 'default' though,
if no parameters were specified or if they were invalid.

But each category is just as relevant as the others so this option
isn't great.

After thinking about it, these are separate indexes so my next
reaction was to have four controllers:

items ( new, create, edit, update and destroy)
found_items ( index )
lost_items ( index )
broken_items ( index )

This would give really clear routes and urls but it means creating
four separate controllers - seems like overkill no?

The third option I've considered is to name three collections in my
routes and add three actions to my items controller:

map.resources :items, :collection => { :lost => :get, :found
=> :get, :broken => :get }

def lost
  @items = Item.lost
end

...and so on.

Again, quite clear routes and descriptive urls but I'm under the
impression that this is a less RESTful approach.

Any thoughts?

Thanks

Gavin

I'd say go with the third one and define the actions on your resource. Then you can define your index action to offer a choice of the available categories (perhaps with a handy record count).

-Rob

Rob Biedenharn http://agileconsultingllc.com
Rob@AgileConsultingLLC.com

thanks Rob,

I also think this is the most simple approach but was really keen to
get a 2nd opinion.

Gavin