how to rest my app to support mobile phone
- by qichunren
I am now going to develop a mobile website both support common html format page and wml format page(Because now a usual web browser on mobile can view html page and some old mobiles only support wml )
First step:
register content type for wml page
config/initializers/mime_types.rb
Mime::Type.register_alias "text/vnd.wap.wml", :wml
Second:
Create two format page for an action in view:
class WelcomeController < ApplicationController
def index
@latest_on_sale_auctions = Auction.latest(15)
respond_to do |format|
format.html
format.wml
end
end
end
It works well as I visit:
http://localhost:3000/welcome
But got: Routing Error
No route matches "/welcome.wml" with {:method=:get}
as I visit:http://localhost:3000/welcome.wml
and it works well as I visit:http://localhost:3000/welcome?format=wml
my config/routes.rb like this:
ActionController::Routing::Routes.draw do |map|
map.root :controller => "welcome"
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end
My rails version is 2.3.5,please help me, I want a restful app,both support html and wml.