I used the same tactics in railscast for mobile to provide an alternative layout for my site in a mobile browser.
When a mobile browser is detected, request.format is set to: mobile, which I defined as the mime type. I created a new layout for mobile devices. If I provide a mobile view (e.g. show.mobile.haml), both the mobile view and the layout are used on mobile devices, and everything works fine.
The problem is that I donβt want to create completely new views, itβs just the layout I want to change. If I do not create the so-called view, the mobile layout will never be used. Since-I can only change both or neither on mobile devices.
What am I missing here? How can I get rails to replace only the layout when I have a mobile user?
ruby-on-rails layout mobile views
Kelly
source share