如何设置 rails 设计 sign_in 路径作为根 url
How to set rails devise sign_in path as a root url
devise_for :admins, path: 'admins'
devise_scope :admin do
root to: "devise/sessions#new"
end
http://localhost:3000/
我想在 url 上方输入时重定向 admins/sign_in 路径,登录页面有时会打开,但每次点击登录按钮后,我都会收到此错误消息,无法登录。如何解决这个问题?
错误:
过滤器链停止为:require_no_authentication 渲染或
重定向
你可以用这个实现同样的效果
routes.rb
root "home#index"
devise_for :admins, path: 'admins'
home_controller.rb
class HomeController < ApplicationController
def index
if not admin_signed_in?
redirect_to admin_session_path
end
end
已登录的用户无法再次登录...
你可以试试这个,在你的 session_controller.rb 添加
class Users::SessionsController < Devise::SessionsController
prepend_before_filter :require_no_authentication, :only => [ :new, :create, :cancel ]
end
看起来您正在尝试在未注销的情况下再次登录同一用户
devise_for :admins, path: 'admins'
devise_scope :admin do
authenticated :admin do
root 'home#index', as: :authenticated_root
end
unauthenticated do
root 'devise/sessions#new', as: :unauthenticated_root
end
end
devise_for :admins, path: 'admins'
devise_scope :admin do
root to: "devise/sessions#new"
end
http://localhost:3000/
我想在 url 上方输入时重定向 admins/sign_in 路径,登录页面有时会打开,但每次点击登录按钮后,我都会收到此错误消息,无法登录。如何解决这个问题?
错误:
过滤器链停止为:require_no_authentication 渲染或 重定向
你可以用这个实现同样的效果
routes.rb
root "home#index"
devise_for :admins, path: 'admins'
home_controller.rb
class HomeController < ApplicationController
def index
if not admin_signed_in?
redirect_to admin_session_path
end
end
已登录的用户无法再次登录...
你可以试试这个,在你的 session_controller.rb 添加
class Users::SessionsController < Devise::SessionsController
prepend_before_filter :require_no_authentication, :only => [ :new, :create, :cancel ]
end
看起来您正在尝试在未注销的情况下再次登录同一用户
devise_for :admins, path: 'admins'
devise_scope :admin do
authenticated :admin do
root 'home#index', as: :authenticated_root
end
unauthenticated do
root 'devise/sessions#new', as: :unauthenticated_root
end
end