Sha256: 8a6e16dee5063a97d97b7f2125cd1ac11d00703c9b410b088b62eb6b9165e066
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
class Ability include CanCan::Ability # ability实例化,并设置权限 # # 作者: 汤建华 # 最后更新时间: 2013-11-23 # # ==== 参数 # * 当前用户 def initialize(user) set_init if user can :manage, "main_index".to_sym if user.role.code == "admin" can :manage, :all else check_role user end if user.freezed!=0 cannot :manage, :all set_init end end can :manage, :root_path end # 初始化权限 # # 作者: 汤建华 # 最后更新时间: 2013-11-23 def set_init can :manage, "main_new".to_sym can :manage, "main_create".to_sym can :manage, "main_logout".to_sym can :manage, "main_wince".to_sym end # 设置验证权限 # # 作者: 汤建华 # 最后更新时间: 2013-11-23 # # ==== 参数 # * 当前用户 def check_role(current_user) fuctions = current_user.role_fuctions fuctions.each do |f| f.routepaths.each do |routepath| path = routepath.controllerpath+"_"+routepath.actionpath can :manage, :"#{path}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
admin-sys-1.1.0 | app/models/ability.rb |