# REST, routes and algorithms

**URL:** <https://www.ruby-forum.com/t/rest-routes-and-algorithms/151873>\
**Category:** Rails\
**Created:** [October 27, 2008, 11:32am UTC](https://www.ruby-forum.com/t/rest-routes-and-algorithms/151873 "2008-10-27T11:32:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ratcheer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/aca169/32.png) [@ratcheer](https://www.ruby-forum.com/u/ratcheer)\
**Post date:** [October 27, 2008, 11:32am UTC](https://www.ruby-forum.com/t/rest-routes-and-algorithms/151873/1 "2008-10-27T11:32:28Z")

</div>

I’m reading the book ‘RESTful web services’ and in the discussion on  
exposing algorithmic resources it says the following:

"  
Most web applications donâ€™t store much state in path variables: they use  
query variables instead. You may have seen URIs like this:  
â€¢ [http://www.example.com/articles?start=20061201&end=20071201](http://www.example.com/articles?start=20061201&end=20071201)

Those URIs would look better without the query variables:  
â€¢ [http://www.example.com/articles/20061201-20071201](http://www.example.com/articles/20061201-20071201)  
"

What is the Rails way for exposing algorithmic resources? Is it via the  
first URL in the example or the second? If it is the second, please can  
you give me some guidance on how to achieve this.  
Thanks

---

<div class="post-metadata">

**Author:** ![ratcheer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/aca169/32.png) [@ratcheer](https://www.ruby-forum.com/u/ratcheer)\
**Post date:** [October 27, 2008, 1:30pm UTC](https://www.ruby-forum.com/t/rest-routes-and-algorithms/151873/2 "2008-10-27T13:30:15Z")

</div>

start, finish = “20061201-20071201”.split(‘-’)

“end” is reserved keyword

Tim C. wrote:

> "
> 
> What is the Rails way for exposing algorithmic resources? Is it via the  
> first URL in the example or the second? If it is the second, please can  
> you give me some guidance on how to achieve this.  
> Thanks

–  
irfani

> **[Irfani.web.id](https://irfani.web.id/)**
>
> Mostly Tech Stuff

Y! irfani\_s

---

<div class="post-metadata">

**Author:** ![ratcheer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/aca169/32.png) [@ratcheer](https://www.ruby-forum.com/u/ratcheer)\
**Post date:** [October 27, 2008, 3:07pm UTC](https://www.ruby-forum.com/t/rest-routes-and-algorithms/151873/3 "2008-10-27T15:07:18Z")

</div>

> Those URIs would look better without the query variables:  
> â€¢ [http://www.example.com/articles/20061201-20071201](http://www.example.com/articles/20061201-20071201)  
> "
> 
> What is the Rails way for exposing algorithmic resources? Is it via the  
> first URL in the example or the second? If it is the second, please can  
> you give me some guidance on how to achieve this.  
> Thanks

Rails conventions says that /articles/20061201-20071201 finds the  
article with the id ‘20061201-20071201’. Anything other than that would  
be unconventional.

There are of course conventions to breaking the conventions, though ; )  
Personally, I’d do something like map.article\_range ‘/articles/:range’,  
:action =\> ‘range’, :requirements =\> {:range =\> /(d+)-(d+)/}. In the  
‘range’ action, I’d do what YangBaikHati suggests above. start, finish =  
params[:range].split(‘-’).
