Order labels by name

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2014-07-30 19:13:35 +03:00
parent 91c1534e59
commit 2ecc79507a
No known key found for this signature in database
GPG Key ID: 627C5F589F467F17
3 changed files with 4 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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)