Couple of quick tips for creating content meant for mobile devices using Ruby on Rails:
- You’ll probably want to setup a new default layout for all templates. You can do that by creating app/views/layouts/application.rhtml and populating it with whatever you want your default layout to be. For instance here’s an unstyled version of the mostest simplest template that Luca posted with GAP as a default rhtml layout:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Valentine</title> </head> <body> <%= @content_for_layout %> </body> </html> - Adaptation of the content type based on the mime types the device claims to accept is also pretty much a necessity. I’m going off the MIME types post pointed to from GAP for this also in creating an ApplicationController that sets content type based on the accept header sent by the browser:
class ApplicationController < ActionController::Base before_filter :set_content_type def set_content_type if @request.accepts.include?( Mime::Type.parse( 'application/vnd.wap.xhtml+xml' ) ) type = 'application/vnd.wap.xhtml+xml' elsif @request.accepts.include?( Mime::Type.parse( 'application/xhtml+xml' ) ) type = 'application/xhtml+xml' else type = 'text/html' end @headers["Content-Type"] = type + "; charset=utf-8" end endThe order for the checks I’m sure is something that just about everyone will have their own opinion about, so I stuck with what that post had.

Pingback: Web es móvil
used it render the same pages on mobile and stand alone web works just fine
just that @request and @headers have been deprecated in recent rails. So use request and headers method instead.
One thing I found out while working on a mobile rails site was that some lower end phones do not like using the redirect_to method with the :controller and :action arguments, but allow hard coding the redirect_to a specific address like eg:
redirect_to “http://m.bublit.com/”
Not the best way of doing things, I know, but it seems to work. I guess you cannot compete with real phone testing.