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