Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 使用移动mime类型设计,401仅显示flash消息_Ruby On Rails_Mobile_Devise_Rails Routing - Fatal编程技术网

Ruby on rails 使用移动mime类型设计,401仅显示flash消息

Ruby on rails 使用移动mime类型设计,401仅显示flash消息,ruby-on-rails,mobile,devise,rails-routing,Ruby On Rails,Mobile,Devise,Rails Routing,我有一个带有Desive 2.0的Rail 3.2.2应用程序,我已经开始将移动视图与之结合。我正在我的应用程序\u controller.rb中使用前置过滤器,以使用移动布局,如下所示: before_filter :adjust_format_for_mobile private def adjust_format_for_mobile if request.env["HTTP_USER_AGENT"] && request.env["HTTP_

我有一个带有Desive 2.0的Rail 3.2.2应用程序,我已经开始将移动视图与之结合。我正在我的
应用程序\u controller.rb中使用
前置过滤器
,以使用移动布局,如下所示:

  before_filter :adjust_format_for_mobile

  private
    def adjust_format_for_mobile
      if request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(iPhone|iPod)/] 

         request.format = :mobile
      end
  end
   Started GET "/" for 127.0.0.1 at 2012-03-21 17:07:35 -0500
   Processing by WellsController#index as HTML
   Completed 401 Unauthorized in 0ms
我在
初始值设定项/mime\u types
中定义了mime类型:

Mime::Type.register_alias "text/html", :mobile
每当我试图访问
路由.rb
中定义的
根路径时:

root :to => "wells#index"
(通过过滤前的
进行保护:对用户进行身份验证!

所呈现的只是Desive flash消息(无HTML):

继续之前,您需要登录或注册

我有必要的移动布局,我缺少什么?桌面版本的行为是您被重定向到
新用户会话路径
,为什么这里不是这样

编辑:

控制台日志如下所示:

  before_filter :adjust_format_for_mobile

  private
    def adjust_format_for_mobile
      if request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(iPhone|iPod)/] 

         request.format = :mobile
      end
  end
   Started GET "/" for 127.0.0.1 at 2012-03-21 17:07:35 -0500
   Processing by WellsController#index as HTML
   Completed 401 Unauthorized in 0ms

此外,这只发生在特定路径(根路径)上。如果我手动转到users/sign\u或users/sign\u,它的工作效果会非常好。然后我可以登录,一切正常。

在此过程中找到了一个wiki: