/archives/:year/:month/:day routes with REST?

I'd recommend against this for usability reasons and seo reasons...but if you are really set on it there is an example in the agile book. Though that uses traditional routing -- restful may be a bit harder...

The domain.com/blog/id-permalink style makes much more sense and will get your more google-fu.

- rob

why REST? will you be doing CRUD operations on them? if it's just an archive, then isn't the routing you have already sufficient?

if you still want REST, (and i'm a rest noob so this may be very wrong), perhaps something like

mydomain.com/blog/year/2007/month/5/day/28

If it's not too late, let me throw in my two cents :slight_smile:

REST != map.resources

This is a common perception, because DHH's posts about REST usually included instructions about map.resources, a feature new to Rails 1.2 that made routing easier *in some cases*.

But you can have a 100% RESTful application just by using map.connect, too. After all, map.resources is just shorthand for a bunch of named routes (and named routes are just map.connect statements).

The url part after blog/ identifies your resource, right? So you can be RESTful:

map.connect /blog/:year:/:month/:day, :controller => :blog, :action => :index

Then your BlogController has:

def index   month = params[:month]   year = params[:year]   day = params[:day]

  @entries = # get entries here end

I'm simplifying, but hopefully you get the idea. You can have a RESTful architecture whether you use map.connect or map.resources.

Jeff softiesonrails.com

Awesome reply Jeff, and a point very well made.

Thanks Douglas! Glad to help.

I think that you should make a blog entry of that, you have the spiel down to a tee.

softiesonrails.com/tags/rest

:slight_smile: