首页 文章

如何休息我的应用程序以支持手机

提问于
浏览
1

我现在要开发一个支持常见的html格式页面和wml格式页面的移动网站(因为现在移动设备上的常用网页浏览器可以查看html页面,而一些旧手机只支持wml)

第一步:

注册wml页面config / initializers / mime_types.rb的内容类型
Mime :: Type.register_alias "text/vnd.wap.wml",:wml

第二步:为视图中的操作创建两个格式页面:

class WelcomeController < ApplicationController
  def index
    @latest_on_sale_auctions = Auction.latest(15)
     respond_to do |format|
       format.html
       format.wml
     end
  end

end

它在我访问时效果很好:http://localhost:3000/welcome但得到:路由错误当我访问时没有路由匹配"/welcome.wml"与{:method =>:get}:http://localhost:3000/welcome.wml

我访问时效果很好: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

我的rails版本是2.3.5,请帮帮我,我想要一个安静的应用程序,都支持html和wml .

1 回答

相关问题