Removed default order by priority on roles (#1720)

This commit is contained in:
Ahmad Farhat 2020-06-02 11:12:33 -04:00 committed by GitHub
parent 4da03957a9
commit 7e27feb70b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -21,7 +21,7 @@ module Rolify
# Gets all roles
def all_roles(selected_role)
@roles = Role.editable_roles(@user_domain)
@roles = Role.editable_roles(@user_domain).by_priority
if @roles.count.zero?
Role.create_default_roles(@user_domain)

View File

@ -54,7 +54,7 @@ module UsersHelper
# Returns a list of roles that the user can have
def role_options
Role.editable_roles(@user_domain).where("priority >= ?", current_user.role.priority)
Role.editable_roles(@user_domain).where("priority >= ?", current_user.role.priority).by_priority
end
# Parses markdown for rendering.

View File

@ -22,7 +22,7 @@ class Role < ApplicationRecord
has_many :users
default_scope { includes(:role_permissions).distinct.order(:priority) }
default_scope { includes(:role_permissions) }
scope :by_priority, -> { order(:priority) }
scope :editable_roles, ->(provider) { where(provider: provider).where.not(name: %w[super_admin denied pending]) }