You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
857 B
36 lines
857 B
|
|
class Ability |
|
include CanCan::Ability |
|
|
|
def initialize(user) |
|
clear_aliased_actions |
|
|
|
user ||= User.new |
|
|
|
if user.persisted? |
|
can :display, Cdao::Jurisprudence |
|
|
|
can :manage, :all |
|
|
|
cannot :destroy, Cdao::Jurisprudence |
|
cannot :destroy, Cdao::Library |
|
cannot :destroy, Cdao::LibrarySubject |
|
cannot :destroy, Cdao::Subject |
|
end |
|
end |
|
|
|
def clear_aliased_actions |
|
super |
|
|
|
# override cancan default aliasing (we don't want to differentiate |
|
# between read and index) |
|
alias_action :destroy, to: :delete |
|
alias_action :edit, to: :update |
|
alias_action :new, to: :create |
|
alias_action :show, to: :read |
|
alias_action :search, to: :index |
|
alias_action :index, :read, to: :display |
|
alias_action :create, :update, to: :modify |
|
alias_action :display, :modify, to: :basic_manage |
|
end |
|
end
|
|
|