Restful dates: from, to


I'm having trouble making my application restful. I want to show posts
between 2 dates.

For example posts between march 2007 and may 2007. I don't know how to
represent this timespan a single resource because it has 2 parts: from
and to. The url I'm looking for is something like this /from/

But that means that there are 3 resources here: "From" resource, "To"
resource and "Posts".

And nested routes would look something like this:

map.resources :from do |from|
  from.resources :to do |to|
    to.resources :posts

Is this solution ok, or there is some more elegant way of solving


How about start date and timespan, so start-dates are the basis of
your url and timespan is a parameter.
Just a thought :slight_smile:

You mean like /from/01-03-2007/posts?to=01-05-2007 ?

This is kind of ugly

Well maybe, but you can get rid of the from and have


and if there is no 'to' you'd just get the posts on the day.

I think that the most natural way would be simply:


This seems like a perfecly acceptable uri from a REST point of view,
and your posts controller can simply look for params[:from], and
params[:to] in the index action

I too am looking for a good way to expose a date parameter in a url
using restful routing...

I'd like to stay away from query string parameters (i.e. ?/&) in
pursuit of cleaner urls without potential caching/search engine
difficulties. For example, I like how Dopplr structures their urls
quite a bit (probably using map.connect?):

... where 2008/01/trips are parameters used to scope journal results
(2008/01 scopes the year/month, and trips filters the results to items
of type 'trip')

Any ideas how I could achieve something similar with
map.resources? :path_prefix can enable the type of parameter passing
I need, but prepending them onto the url doesn't yield the same
logical structure I'm looking for (i.e. ability for a visitor to chop
a parameter off the url and find herself a level higher in the site's
information architecture).

- Adam