# Routing optimisation

**URL:** <https://www.ruby-forum.com/t/routing-optimisation/185951>\
**Category:** Rails\
**Created:** [March 29, 2010, 5:23pm UTC](https://www.ruby-forum.com/t/routing-optimisation/185951 "2010-03-29T17:23:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![droopy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/47e85d/32.png) [@droopy](https://www.ruby-forum.com/u/droopy)\
**Post date:** [March 29, 2010, 5:23pm UTC](https://www.ruby-forum.com/t/routing-optimisation/185951/1 "2010-03-29T17:23:03Z")

</div>

I’m kind of a newbie, so I don’t understand all the power of routes and  
implicit render that can be found in scaffolding

I have an application that have several views which are quite different  
but based on the controller action.

What I would like is to be able to define routes that would go through  
the same controller action but would diverge on various views

Something like

/display/:id/:variant

would go to :action=\> display and then  
the render would go to display\_variant  
Right now, all I can do is to render the display.html.erb

Or maybe  
/display\_variant/:id

would do the same

I would be able to have then urls such as  
/display/25/tall  
/display/25/wide  
display/25/mix

and I would only design  
display\_tall.html.erb  
display\_wide.html.erb  
…

Any thoughts ?

Thanks in advance

Christophe

---

<div class="post-metadata">

**Author:** ![droopy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/47e85d/32.png) [@droopy](https://www.ruby-forum.com/u/droopy)\
**Post date:** [March 30, 2010, 2:15am UTC](https://www.ruby-forum.com/t/routing-optimisation/185951/2 "2010-03-30T02:15:40Z")

</div>

This is probably best done with CSS… ie max device width. However,  
you could leverage the format option in rails. Normally you get things  
like .html, .js, .xml as pretty standard. In your case, the “variant”  
could just be a format (iPhone is a pretty typical one). Basically add  
another view file, like display.js.erb or display.iphone.erb or  
display.tall.erb. You may need to define the mime-types for the  
non-standard ones.
