# Advise request: plugin routes with version prefix

**URL:** <https://www.ruby-forum.com/t/advise-request-plugin-routes-with-version-prefix/160458>\
**Category:** Rails\
**Created:** [February 16, 2009, 4:43pm UTC](https://www.ruby-forum.com/t/advise-request-plugin-routes-with-version-prefix/160458 "2009-02-16T16:43:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![raphael\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7c8e57/32.png) [@raphael\_b](https://www.ruby-forum.com/u/raphael_b)\
**Post date:** [February 16, 2009, 4:43pm UTC](https://www.ruby-forum.com/t/advise-request-plugin-routes-with-version-prefix/160458/1 "2009-02-16T16:43:06Z")

</div>

Hi,

I’m developing an API as a rails plugin, and I would like to be able  
to install multiple versions in parallel.  
The routing is not a big problem, I can define routes with the correct  
prefix. The problem would be with the controller though.  
I think it would be preferable to have the controller keep its name  
across versions, but then, how can the routing know which controller  
should handle the request?

If I have versions v1 and v2 of the api installed, the plugins would  
provide these routes:  
connect '/rest/simple/v1/:controller/:action/:id"  
connect '/rest/simple/v2/:controller/:action/:id"

To make it work, would the only solution be to have the controllers  
called  
Rest::Simple::V1::MyController and Rest::Simple::V2::MyController ?

I currently don’t see an alternate solution. Does anyone here have one?

Thanks in advance

Raphaël

–  
Web database: [http://www.myowndb.com](http://www.myowndb.com)  
Free Software Developers Meeting: [http://www.fosdem.org](http://www.fosdem.org)

---

<div class="post-metadata">

**Author:** ![raphael\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7c8e57/32.png) [@raphael\_b](https://www.ruby-forum.com/u/raphael_b)\
**Post date:** [February 27, 2009, 9:42pm UTC](https://www.ruby-forum.com/t/advise-request-plugin-routes-with-version-prefix/160458/2 "2009-02-27T21:42:27Z")

</div>

Hi Raphaël,

Changing the version of an API is never just about the version, the  
implications are more often than not pretty deep.

My take on your case would be to publish your application as the  
version itself, not clouding each version with overly complex code to  
handle version specific code and version specific transformations…

Right now it might seem as 2 version… how about in 5 years from  
now…

So, instead of having:

connect ‘/rest/simple/v1/:controller/:action/:id’  
connect ‘/rest/simple/v2/:controller/:action/:id’

You would have:  
connect ‘/rest/simple/:controller/:action/:id’

in two different applications…

Food for thoughts… but no matter what you determine… post it there  
so we can all learn for your reflection!

have a good day!

Jean-Marc

> **[M2i3 - Connecter les besoins aux solutions](https://m2i3.com/)**
>
> Nous sommes M2i3, des "socials-geeks" passionnés par le web, l'infonuagique et les logiciels. Nous vous présentons IncognitoDesk Après des an ...
