class ApplicationPolicy
  attr_reader :user, :record

  def initialize(user, record)
    @user = user
    @record = record
  end

  def index?
    false
  end

  def show?
    scope.where(:id => record.id).exists?
  end

  def create?
    false
  end

  def new?
    create?
  end

  def update?
    false
  end

  def edit?
    update?
  end

  def destroy?
    false
  end

  def scope
    Pundit.policy_scope!(user, record.class)
  end
end


class ApplicationPolicy
  attr_reader :user, :record

  def initialize(user, record)
    @user = user
    @record = record
  end

  def index?
    true
  end

  def show?
    true
  end

  def create?
    is_admin?
  end

  def new?
    create?
  end

  def update?
    is_admin?
  end

  def edit?
    update?
  end

  def destroy?
    is_admin?
  end

  def scope
    Pundit.policy_scope!(user, record.class)
  end

  def permitted_for?(field, operation)
    permitted?(field) && send("#{operation}?")
  end

  def permitted?(field)
    permitted_attributes.values.first.include? field
  end

  protected
  def is_admin?
    user.try(:admin?) || false
  end

  def done_by_onwer_or_admin?
    is_owned_by?(user) || is_admin?
  end

  def is_owned_by?(user)
    user.present? && record.user == user
  end
end

Add helper methods to application policy
Add helper methods to application policy
