Add ordered scope

This commit is contained in:
Urban Rotnik 2020-01-30 13:42:02 +01:00
parent 1bb54d20cf
commit 3db48c44f7
3 changed files with 6 additions and 5 deletions

View file

@ -69,7 +69,7 @@ class GlobalActivitiesController < ApplicationController
end
def team_filter
render json: current_user.teams.order('LOWER(name)').global_activity_filter(activity_filters, params[:query])
render json: current_user.teams.ordered.global_activity_filter(activity_filters, params[:query])
end
def user_filter

View file

@ -12,6 +12,7 @@ class Team < ApplicationRecord
after_create :generate_template_project
scope :teams_select, -> { select(:id, :name).order(name: :asc) }
scope :ordered, -> { order('LOWER(name)') }
auto_strip_attributes :name, :description, nullify: false
validates :name,

View file

@ -73,7 +73,7 @@
<%= hidden_field(:user, :current_team_id) %>
<div class="dropdown-header"><%= t('nav.team_switch_title') %></div>
<div class="team-container">
<% current_user.teams.order('LOWER(name)').each do |team| %>
<% current_user.teams.ordered.each do |team| %>
<li class="team-name-item">
<a href="#"
data-id="<%= team.id %>"
@ -191,9 +191,9 @@
</li>
<li>
<%= link_to Constants::ACADEMY_TR_LINK,
class: "academy-link flag",
title: I18n.t('nav.academy_tooltip'),
target: :_blank do
class: "academy-link flag",
title: I18n.t('nav.academy_tooltip'),
target: :_blank do
%>
<div class="icon-container">
<span class="fas fa-graduation-cap"></span>