Mobylette: Mobile Requests Handling (GEM)

Posted by Tiago Scolari on Sep 3, 2011
In Development, Ruby
Tags

In the last few days have been working on this gem. It’s named Mobylette and it works by identifying mobile requests in your app, and handling them with a new .mobile format.

Once you have it installed on your application, adding respond_to_mobile_requests to your controller will enable it to deal with mobile requests. It will automatically look for a .mobile.erb (.haml, or whatever) when a request comes from a mobile device. Also you can call the mobile type from a respond_to block:

respond_to do |format|
  format.html     {...}
  format.mobile {...}
end

Mobylette can handle template fall back in case you dont have a .mobile for that action. By default it will fall back to the request original format, but you can disable or change it to a specific format. Please refer to the documentation for more information.