hol*_*kin 4 authentication ruby-on-rails devise
我已经开始使用Devise gem并且现在尝试实现代码,因此我的Web应用程序将需要登录我的应用程序上的每个页面.我已根据此指令将以下代码添加到routes.rb:
authenticated :user do
root to: 'home#index', as: :authenticated_root
end
root to: redirect('/users/sign_in')
Run Code Online (Sandbox Code Playgroud)
但它不起作用.当我转到任何页面时 - 它只是打开该页面,而不是将我转发到sign_in页面.有谁可以澄清我错过了什么?任何帮助,将不胜感激.
将其添加到您的app控制器
class ApplicationController < ActionController::Base
...
before_action :authenticate_user!
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1448 次 |
| 最近记录: |