项目列表根据ID排序

This commit is contained in:
sw 2015-07-01 17:02:30 +08:00
parent d48a733502
commit 749b9c4429
2 changed files with 2 additions and 2 deletions

View File

@ -34,7 +34,7 @@ class AdminController < ApplicationController
def projects
@status = params[:status] || 1
scope = Project.status(@status).order('lft')
scope = Project.status(@status).order('id asc')
scope = scope.like(params[:name]) if params[:name].present?
@projects = scope.where(project_type: Project::ProjectType_project).all

View File

@ -839,7 +839,7 @@ class Project < ActiveRecord::Base
# Yields the given block for each project with its level in the tree
def self.project_tree(projects, &block)
ancestors = []
projects.sort_by(&:lft).each do |project|
projects.sort_by(&:id).each do |project|
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
ancestors.pop
end