Mobile-Fu将桌面IE检测为平板电脑

时间:2013-01-25 15:56:10

标签: ruby-on-rails ruby-on-rails-3 internet-explorer mobile-fu

通常IE的多数发送此useragent

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; MS-RTC LM 8)

但有些IE发送此Useragent

  Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Tablet PC 2.0; .NET4.0C; .NET4.0E; MS-RTC LM 8)

我有2个布局,application.html.haml& application.mobile.haml
由于第二个包括“Tablet PC 2.0”,因此Mobile-Fu将格式设置为:平板电脑,它不会在我的rails App中呈现布局。

请帮我解决这个问题。谢谢!

1 个答案:

答案 0 :(得分:0)

暂时我通过更改用户代理来修复,如果请求来自IE&包括平板电脑,

class ApplicationController < ActionController::Base

  before_filter :change_user_agent_for_ie

  def change_user_agent_for_ie
    if request.env["HTTP_USER_AGENT"].include?("Tablet PC 2.0") && (request.env["HTTP_USER_AGENT"].include?("MSIE"))
      request.env["HTTP_USER_AGENT"] = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; MS-RTC LM 8)"
    end
  end

不确定永久修复的是什么。