HowTo: Add mobile support
October 10, 2008 Leave a comment
You can also refer here.
First, install the plugin using the following command
ruby script/plugin install git://github.com/brendanlim/mobile-fu.git
Next, in your controllers/application.rb, add the following line:
has_mobile_fu
You can now create a .mobile file for rails to render in place of the html files. And rails will automatically load these files once rails detects that the request to view your page is coming from a mobile source.
If you want to let the users choose between mobile and html view, you can change the session variable
session[:mobile_view]
to true to set users to use the mobile view, false otherwise.
TESTING using Firefox:
To test mobile browsing capabilities using firefox, install the user agent switcher addon. This addon can be found here. After installation, go to
Tools -> User Agent Switcher -> Options -> Options...
and add the user agent of the phone you want to test. A list of user agents for mobile phones is available here.