【发布时间】:2014-08-24 21:56:29
【问题描述】:
当用户登录时,用户会被重定向到 /dashboard/index。所以 /dashboard/index 受保护:
class DashboardController < ApplicationController
before_action :authenticate_user!
def index
end
end
现在,如果有人尝试在未登录的情况下直接访问 /dashboard/index。用户将被重定向到 /users/sign_in,并显示闪烁消息“您需要先登录或注册才能继续。”
我怎样才能让用户重定向到 root_path(并且仍然得到那个 flash 消息)?
我尝试过不成功:
class ApplicationController < ActionController::Base
def new_user_session_path(resource)
root_path
end
【问题讨论】:
-
在这里查看我的答案stackoverflow.com/a/24232071/1297435
标签: ruby-on-rails devise