Sha256: e0c8fd7156ae848e8f5fb81e30c84f2fa0fde9baa8ffc36d01a1beecfc42dfa5
Contents?: true
Size: 898 Bytes
Versions: 2
Compression:
Stored size: 898 Bytes
Contents
require 'cancan_namespace' module Sunrise module Models class Ability include CanCanNamespace::Ability attr_accessor :context, :user def initialize(user, context = nil) alias_action :delete, :to => :destroy @user = (user || ::User.new) # guest user (not logged in) @context = context if @user.current_role && @user.current_role.role_type send @user.current_role.role_type.code else guest end end def admin can :manage, :all can :manage, :all, :context => :sunrise # User cannot destroy self account cannot :destroy, ::User, :id => @user.id, :context => :sunrise # User cannot destroy root structure cannot :destroy, ::Structure, :kind => ::StructureType.main.id, :context => :sunrise end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sunrise-cms-0.4.2 | lib/sunrise/models/ability.rb |
sunrise-cms-0.4.1 | lib/sunrise/models/ability.rb |