Supporting Mobile Devices in Ruby on Rails

Eran Kampf picture Eran Kampf · Jul 21, 2009 · Viewed 20.6k times · Source

What is the best way to develop a rails application that has special views for different mobile devices? Basically I'm looking for something like this ASP.NET MVC solution: http://www.hanselman.com/blog/MixMobileWebSitesWithASPNETMVCAndTheMobileBrowserDefinitionFile.aspx

Answer

ideasasylum picture ideasasylum · Jul 21, 2009

You might be looking for mobile_fu. It's a plugin that automatically changes the Rails format from :html to :mobile for Nokia, Blackberry, iPhone and Palm users. You can then just provide an {action}.mobile.erb to complement {action}.html.erb and it will render the mobile view. If you need something more fine-grained, it allows you to do:

is_mobile_device?

and there's various other helper methods