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
-
1Perhaps you could be more specific about what that ASP.NET solution actually does, that actually you need? – ideasasylum Jul 21 '09 at 20:54
7 Answers
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

- 2,130
- 1
- 17
- 21
Two articles that use the iPhone as an example of serving up a different view based on a mobile sub-domain or a by detecting the user-agent. Essentially you'll create a different view using something like viewname.iphone.erb or viewname.mobile.erb and set the request.format variable to iphone or mobile respectively.
iPhone on Rails - Creating an iPhone optimised version of your Rails site using iUI and Rails 2

- 1,872
- 1
- 19
- 23
I found this railscast extremely helpful for this situation: http://railscasts.com/episodes/199-mobile-devices
Hope it helps somebody out.

- 1,297
- 17
- 19
I recently wrote an article about this which you might find useful:
http://www.arctickiwi.com/blog/2-mobile-enable-your-ruby-on-rails-site-for-small-screens
Hope that helps
Jonno

- 2,303
- 1
- 20
- 18
I just saw a really illuminating video on this: http://www.engineyard.com/video/12678746 . There is a lot more to a decent mobile web experience then directly porting pages.

- 1,023
- 11
- 14
You might want to try Mobvious - https://github.com/jistr/mobvious
Detects mobiles vs. desktops + tablets, or if you want, detects mobile vs. tablets vs. desktops.
It also has support for manual selection by users (overriding the detection) if you want to allow users to manually switch interface versions.
And there is an extension mobvious-rails that adds some helpers to your controllers, views and CoffeeScript.

- 1,331
- 1
- 10
- 5