# Iphone Routes Help

**URL:** <https://www.ruby-forum.com/t/iphone-routes-help/146606>\
**Category:** Rails\
**Created:** [August 22, 2008, 11:08pm UTC](https://www.ruby-forum.com/t/iphone-routes-help/146606 "2008-08-22T23:08:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff\_Larkin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7993a0/32.png) [@Jeff\_Larkin](https://www.ruby-forum.com/u/Jeff_Larkin)\
**Post date:** [August 22, 2008, 11:08pm UTC](https://www.ruby-forum.com/t/iphone-routes-help/146606/1 "2008-08-22T23:08:53Z")

</div>

Hi all. I recently implemented an iphone interface to a rails CMS  
using an iphone subdomain, since this seems to be the most common way  
to do this among rails apps. I didn’t think about the implications  
this would have on my page caching, however. I’d prefer to  
reimplement this with a /iphone or /m suffix to the site. I could do  
this in routes.rb via a namespace, but that requires separate  
controllers for each namespace. I suppose I could use polymorphism to  
keep these special controllers fairly dry, but it still seems like  
over-kill. I tried adding an ‘iphone/blah’ route to match every  
‘blah’ route, but that doesn’t seem very dry and the format isn’t  
persistent. Am I totally overlooking a very simple way to implement  
this? Here’s some routes, if they might help with an answer:

map.root :controller =\> ‘page’, :action =\> ‘index’

# map.iphone ‘iphone/’ :controller =\> ‘page’, :action =\>

‘index’, :format =\> ‘iphone’  
map.schedule ‘schedule’, :controller =\> ‘schedule’, :action =\>  
‘index’

# map.iphone\_schedule ‘iphone/schedule’, :controller =\>

‘schedule’, :action =\> ‘index’, :format =\> ‘iphone’  
map.page ‘:stub’, :controller =\> ‘page’, :action =\> ‘show’

# map.iphone\_page ‘iphone/:stub’, :controller =\> ‘page’, :action =\>

‘show’, :format =\> :iphone

Thanks for any suggestions.  
-Jeff
