diff --git a/app/models/manageiq/providers/openstack/cloud_manager/cloud_tenant.rb b/app/models/manageiq/providers/openstack/cloud_manager/cloud_tenant.rb index a56c7dcbb..c99bf5c66 100644 --- a/app/models/manageiq/providers/openstack/cloud_manager/cloud_tenant.rb +++ b/app/models/manageiq/providers/openstack/cloud_manager/cloud_tenant.rb @@ -59,7 +59,7 @@ def default_security_group # then return the security group with the most VMs in it. security_groups.left_joins(:network_port_security_groups) .group(:id) - .order('COUNT(network_ports_security_groups.security_group_id) DESC NULLS LAST') + .order(Arel.sql('COUNT(network_ports_security_groups.security_group_id) DESC NULLS LAST')) .first end