app/models/ability.rb
def common_abilities_for_admins(user)
    can :access, Admin
    can :manage, :all if user.is_admin?

    conf_ids_for_organizer = Conference.with_role(:organizer, user).pluck(:id)
    conf_ids_for_cfp = Conference.with_role(:cfp, user).pluck(:id)
    conf_ids_for_info_desk = Conference.with_role(:info_desk, user).pluck(:id)

    if conf_ids_for_organizer
      # To access splashpage of their conference if it is not public
      can :show, Conference, id: conf_ids_for_organizer
      # To access conference/proposals/registrations
      can :manage, Registration, conference_id: conf_ids_for_organizer
      # To access conference/proposals
      can :manage, Event, program: { conference_id: conf_ids_for_organizer }
      # To access comment link in menu bar
      can :index, Comment, commentable_type: 'Event',
                           commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id)
    end

    if conf_ids_for_cfp
      # To access comment link in menu bar
      can :index, Comment, commentable_type: 'Event',
                           commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
      # To access conference/proposals
      can :manage, Event, program: { conference_id: conf_ids_for_cfp }
    end

    if conf_ids_for_info_desk
      # To access conference/proposals/registrations
      can :manage, Registration, conference_id: conf_ids_for_info_desk
    end
  end
# Abilities for users with roles wandering around in non-admin views.
Abilities for users with roles wandering around in non-admin views.
Abilities for users with roles wandering around in non - admin views .
def common_abilities_for_admins(user)
    can :access, Admin
    can :manage, :all if user.is_admin?
    conf_ids_for_organizer = Conference.with_role(:organizer, user).pluck(:id)
    conf_ids_for_cfp = Conference.with_role(:cfp, user).pluck(:id)
    conf_ids_for_info_desk = Conference.with_role(:info_desk, user).pluck(:id)
    if conf_ids_for_organizer
      can :show, Conference, id: conf_ids_for_organizer
      can :manage, Registration, conference_id: conf_ids_for_organizer
      can :manage, Event, program: { conference_id: conf_ids_for_organizer }
      can :index, Comment, commentable_type: 'Event',
                           commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id)
    end
    if conf_ids_for_cfp
      can :index, Comment, commentable_type: 'Event',
                           commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
      can :manage, Event, program: { conference_id: conf_ids_for_cfp }
    end
    if conf_ids_for_info_desk
      can :manage, Registration, conference_id: conf_ids_for_info_desk
    end
  end
def common_abilities_for_admins ( user ) can :access , Admin can :manage , :all if user . is_admin? conf_ids_for_organizer = Conference . with_role ( :organizer , user ) . pluck ( :id ) conf_ids_for_cfp = Conference . with_role ( :cfp , user ) . pluck ( :id ) conf_ids_for_info_desk = Conference . with_role ( :info_desk , user ) . pluck ( :id ) if conf_ids_for_organizer can :show , Conference , id : conf_ids_for_organizer can :manage , Registration , conference_id : conf_ids_for_organizer can :manage , Event , program : { conference_id : conf_ids_for_organizer } can :index , Comment , commentable_type : 'Event' , commentable_id : Event . where ( program_id : Program . where ( conference_id : conf_ids_for_organizer ) . pluck ( :id ) ) . pluck ( :id ) end if conf_ids_for_cfp can :index , Comment , commentable_type : 'Event' , commentable_id : Event . where ( program_id : Program . where ( conference_id : conf_ids_for_cfp ) . pluck ( :id ) ) . pluck ( :id ) can :manage , Event , program : { conference_id : conf_ids_for_cfp } end if conf_ids_for_info_desk can :manage , Registration , conference_id : conf_ids_for_info_desk end end
Abilities for users with roles wandering around in non-admin views.
Abilities for users with roles wandering around in non - admin views .
# To access splashpage of their conference if it is not public # To access conference/proposals/registrations # To access conference/proposals # To access comment link in menu bar # To access comment link in menu bar # To access conference/proposals # To access conference/proposals/registrations
user