Commit 2ecc7950 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Order labels by name

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 91c1534e
......@@ -7,7 +7,7 @@ class Projects::LabelsController < Projects::ApplicationController
respond_to :js, :html
def index
@labels = @project.labels.order('title ASC').page(params[:page]).per(20)
@labels = @project.labels.order_by_name.page(params[:page]).per(20)
end
def new
......
......@@ -9,6 +9,8 @@ class Label < ActiveRecord::Base
# Dont allow '?', '&', and ',' for label titles
validates :title, presence: true, format: { with: /\A[^&\?,&]*\z/ }
scope :order_by_name, -> { reorder("labels.title ASC") }
def name
title
end
......
......@@ -36,7 +36,7 @@
%fieldset
%legend Labels
%ul.nav.nav-pills.nav-stacked.nav-small.labels-filter
- @project.labels.each do |label|
- @project.labels.order_by_name.each do |label|
%li{class: label_filter_class(label.name)}
= link_to labels_filter_path(label.name) do
= render_colored_label(label)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment