Sha256: 6fa53775112f2e7d4f0b222763fbb7b516aa669d7cf82c2341a2676f970e6149

Contents?: true

Size: 546 Bytes

Versions: 2

Compression:

Stored size: 546 Bytes

Contents

module Answers
  class Ability
    include CanCan::Ability

    def initialize(user)

      @q_and_a = [Question, Answer]

      can :read, :all
      can :manage, user

      if user.is_admin
        can :manage, :all
      end

      if user.is_editor
        can :manage, @q_and_a
      end

      if user.is_writer
        can :create, @q_and_a
        # can [:update, :destroy], @q_and_a, status: "Draft", user_id: user.id
        # can [:update, :destroy], @q_and_a, guide: { user_id: user.id, status: "Draft" }
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
answers-core-0.0.0.2 app/models/answers/ability.rb
answers-core-0.0.0 app/models/answers/ability.rb