我正在設計一個簡單的博客系統,我是一個rails新手。Rolify單獨或我需要CanCan/Authority
我想添加到我的應用程序的角色+授權系統,所以我期待一些CanCan,Rolify或Authority的組合。
在這一刻,我已經使用名稱空間將adminpanel與前端分開,並創建了一個簡單的角色magamenent:在我的admin_controller中,我檢查角色並授權訪問。
class AdminController < ApplicationController
layout 'admin/application'
before_action :require_logged_admin
protected
def require_logged_admin
unless signed_in? && current_user.can_access_admin?
flash[:error] = "Only admins can access this section"
redirect_to root_path
end
end
end
我只需要爲管理(管理/編輯)一對夫婦角色和夫婦寄存器用戶角色(可以評論,不能發表評論)的:我只能使用Rolify或者我需要增加一個授權系統? CanCan和Authority之間是一個簡單實現的最佳解決方案(可以,不能)?