错误的用户名/密码时设计错误消息

时间:2014-08-17 03:48:43

标签: ruby-on-rails ruby-on-rails-4 devise

我的问题是,当Devise登录失败时,我没有看到任何错误消息。当发生这种情况时,我被重定向到Devise :: SessionsController #new,这没有设置任何错误

Started POST "/users/sign_in" for 127.0.0.1 at 2014-08-17 06:30:59 +0300
Processing by Devise::SessionsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"4ZgT4DtyyNYNGHRbwCVASolL3CQEqIeMtPlOOy7EBik=", "user"=>{"username"=>"setdddd", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Войти"}
Completed 401 Unauthorized in 3ms
Processing by Devise::SessionsController#new as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"4ZgT4DtyyNYNGHRbwCVASolL3CQEqIeMtPlOOy7EBik=", "user"=>{"username"=>"setdddd", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Войти"}
[]
  Rendered devise/shared/_links.erb (0.1ms)
  Rendered devise/sessions/new.html.erb within layouts/application (40.0ms)
  Rendered application/_header.erb (0.5ms)
  Rendered application/_footer.erb (0.0ms)
Completed 200 OK in 50ms (Views: 47.8ms | ActiveRecord: 0.0ms)

所以问题是设计配置中是否有任何开关允许我向用户显示错误消息,而不仅仅是重定向?

1 个答案:

答案 0 :(得分:1)

您是否在适当的时候输出flash messages?根据情况(即登录失败等),它看起来像设置flash [:notice]和flash [:alert]。由您来决定是否将这些值输出到您的页面。有关更多详细信息,请参阅设计README