From 1c825df5492938882310a9e7d4081401e9e63c37 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 8 Jul 2012 07:40:31 +0000 Subject: [PATCH] Adds a scope for sorting groups. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9947 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/groups_controller.rb | 2 +- app/models/group.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index e1c13969d..244fa57b2 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -25,7 +25,7 @@ class GroupsController < ApplicationController helper :custom_fields def index - @groups = Group.find(:all, :order => 'lastname') + @groups = Group.sorted.all respond_to do |format| format.html diff --git a/app/models/group.rb b/app/models/group.rb index 61266d97a..0eba591b5 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -29,6 +29,8 @@ class Group < Principal before_destroy :remove_references_before_destroy + scope :sorted, order("#{table_name}.lastname ASC") + safe_attributes 'name', 'user_ids', 'custom_field_values',