Sha256: a59b8c1b77c845319016b6cb2d3c0c1b1a3965b8fdeb20f228e783194aeb3c33
Contents?: true
Size: 1.1 KB
Versions: 3
Compression:
Stored size: 1.1 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
admin-sys-1.0.2 | app/models/ability.rb |
admin-sys-1.0.1 | app/models/ability.rb |
admin-sys-1.0.0 | app/models/ability.rb |