我正在关注 Michael Hartl RoR 教程,但在此过程中实现了 Rollify 和 Authority。我以前从未使用过权威,我想知道以下 before_action 是否适合权威使用
# app/controllers/users_controller.rb
class UsersController < ApplicationController
before_action :logged_in_user, only: [:edit, :update]
.
.
.
private
def user_params
params.require(:user).permit(:name, :email, :password,
:password_confirmation)
end
# Before filters
# Confirms a logged-in user.
def logged_in_user
unless logged_in?
flash[:danger] = "Please log in."
redirect_to login_url
end
end
end
def logged_in_user
将ApplicationAuthorizer 类的内部放入以供将来使用会是“良好的编程习惯”吗?