class Ability
  include CanCan::Ability

  # Initialize the ability of user.
  #
  # @param user [User] The current user.
  def initialize(user)
    return unless user

    can :manage, :all if user.administrator?
  end
end

class Ability
  include CanCan::Ability

  # Initialize the ability of user.
  #
  # @param user [User] The current user.
  def initialize(user)
    # TODO: Replace with just the symbols when Rails 5 is released.
    can :read, Course, status: [Course.statuses[:published], Course.statuses[:opened],
                                'published', 'opened']

    return unless user

    can :manage, :all if user.administrator?
  end
end

Allow courses to be read by anyone when it is open.
Allow courses to be read by anyone when it is open.
