我有一个Rail 3.2.2应用与Devise 2.0,我已经开始将移动视图与。我在我的application_controller.rb
使用before_filter
使用移动布局如下:设计与移动MIME类型,401只显示Flash消息
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
我已在MIME类型initializers/mime_types
定义:
Mime::Type.register_alias "text/html", :mobile
每当我试图访问root_path
中定义routes.rb
:
root :to => "wells#index"
(其经由before_filter :authenticate_user!
保护)
所有这一切呈现在制定闪光灯消息(无任何HTML):
You need to sign in or sign up before continuing
我有必要的移动布局,我缺少什么吗?桌面版本的行为是你被重定向到new_user_session_path
,为什么在这里不是这种情况?
编辑:
控制台日志如下:
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
另外,这仅与该特定路径(根路径)时发生。如果我手动去用户/ sign_up或用户/ sign_in它完美的作品。我可以登录,一切正常。