how to rest my app to support mobile phone

Posted by qichunren on Stack Overflow See other posts from Stack Overflow or by qichunren
Published on 2010-01-25T06:02:07Z Indexed on 2010/06/01 10:03 UTC
Read the original article Hit count: 436

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about rest