Mobu
Mobu provides a Rails controller concern called DetectMobile. Mobu does server-side User Agent detection to categorize requests as mobile, tablet, or default. Mobu modifies your rails view paths based on the request type.
Install
Add this line to your Gemfile:
gem 'mobu'
Include the module in your ApplicationController:
class ApplicationController
include Mobu::DetectMobile
Create directories for views_mobile
and views_tablet
:
mkdir app/views_mobile
mkdir app/views_tablet
Usage
Put the view/partial files that you want to override in the appropriate directories.
To allow mobile users to switch to the full site view, add a link to a mobile view:
app/views_mobile/_footer.haml
= link_to("View Full Site", prefer_full_site_url)
To allow full site users to switch to the mobile view, add a link to a default view:
app/views_mobile/_footer.haml
- if mobile_browser?
= link_to("View Mobile Site", prefer_mobile_site_url)
Credits
The view path modification techinique was taken from Scott W. Bradley's post here
A similar project is Brendan Lim's mobile-fu