在带有(Gemfile)的应用程序中:
gem "devise", ">= 2.1.2"
gem 'rails', '3.2.8'
gem 'jquery_mobile_rails'
在添加 jquery-mobile 之前,一切正常,当输入无效数据时,我得到带有错误消息和日志的页面:
Started POST "/users/sign_in" for 127.0.0.1 at 2012-11-28 12:01:13 -0500
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"jLtHS2q0wO+tgswm9VM2/EiuTiq7J9Wwp8d65t/RSGE=", "user"=>{"email"=>"", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"}
Completed 401 Unauthorized in 0ms
Processing by Devise::SessionsController#new as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"jLtHS2q0wO+tgswm9VM2/EiuTiq7J9Wwp8d65t/RSGE=", "user"=>{"email"=>"", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"}
Rendered devise/shared/_links.html.erb (0.8ms)
Rendered devise/sessions/new.html.erb within layouts/application (3.2ms)
Rendered layouts/_navigation.html.erb (0.5ms)
Rendered layouts/_messages.html.erb (0.0ms)
Completed 200 OK in 29ms (Views: 28.9ms)
添加 jquery-mobile 后,使用正确数据登录时工作正常,但使用无效数据我得到 401 并且不重定向注意。在 http 响应中(使用 firebug 查看)仅显示带有“无效电子邮件”(不是 html 代码或 json)之类的错误消息,并且 jquery-mobile 显示“错误加载页面”。
Started POST "/users/sign_in" for 127.0.0.1 at 2012-11-27 21:32:45 -0500
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"EYx56pui4v6trcuzmXQuhzY2BDHwqrADepKuySx9ub0=", "user"=>{"email"=>"test@test.net", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"}
Completed 401 Unauthorized in 0ms
我生成了默认设计控制器和默认视图。
如何使用 jquery mobile 处理设计的错误消息?