How can I route a mobile root differently than a non-mobile one in Rails?
I am building a small website in Ruby on Rails and using jQuery Mobile for mobile-friendly views.
When you view the site through a desktop browser, the root points to a specific page (let's call it "home-page") so that the URLs index looks like this: example.com/pages/home-page.
A mobile user can click a link start a mobi开发者_运维技巧le session, but when that happens, instead of getting a mobile version of example.com/pages/home-page, I want the mobile user to redirect to example.com/pages (which, of course, is pages#index) to work correctly with my mobile views.
Any pointers on how to accomplish this? Is there some sort of conditional I need to pass in my routes? Links to other resources on the web is fine also. I've tried searching but haven't found quite the answer I'm looking for.
Thanks in advance; you all are great.
Ah, I figured it out myself.
I ended up putting this in the application view:
<%= link_to "Mobile Site", pages_url(:mobile => 1) %>
精彩评论