自定义设计:会话控制器故障 [英] Custom Devise: Sessions Controller Failure
问题描述
我的自定义Devise Sessions控制器不让我登录。尝试自定义Devise控制器时遇到了一些困难,但我无法确定这里发生了什么。
My custom Devise Sessions controller isn't letting me sign in. I've had several difficulties trying to customize the Devise controllers, but I can't figure out what's going on here.
当我尝试登录时,页面(会话#新)只是重新呈现。如何让我的自定义控制器恢复到完整的功能?
When I try to sign in, the page (sessions#new) simply re-renders. How can I get my custom controller back to full functionality?
# controllers/sessions_controller
class SessionsController < Devise::SessionsController
skip_before_filter :store_last_attempted_location
skip_after_filter :store_last_successful_location
def new
super
end
def create
super
end
def destroy
super
end
end
我的路线
#config/routes.rb
devise_for :users, :controllers => { :sessions => "sessions", :registrations => "registrations" }
提前感谢
推荐答案
如果登录页面在输入用户凭据后重新呈现,则表示凭据无效,导致重新呈现。但是,应该会在重新渲染的页面上导致闪烁的消息,因为Devise使用Flash消息让应用程序用户知道登录是成功还是失败。
If the sign in page is re-rendered after entering the user credentials then it means that the credentials are invalid which is resulting in the re-rendering. But that should have resulted in a flash message on the re-rendered page as Devise uses flash messages to let the application users know if sign in was successful or failure.
确保您在 application.html.erb
中显示Flash消息:
Make sure that you are displaying flash messages in application.html.erb
as:
<% flash.each do |name, msg| %>
<%= content_tag :div, msg %>
<% end %>
这篇关于自定义设计:会话控制器故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!