Tiago Scolari

bits for fun

Mobylette: Mobile Requests Handling (GEM)

2011-09-03

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.