summaryrefslogtreecommitdiffstats
path: root/app/controllers/projects_controller.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-11-02 20:44:11 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-11-02 20:44:11 +0000
commitf5e5822945901bef9302315927d1a31ef8dd0ef4 (patch)
tree7133fcc11f81e14d4b7c802c8c64d7c6aa1a2018 /app/controllers/projects_controller.rb
parent655a4a1ba0f4abceeb68b1e633a2fff3310b4d55 (diff)
downloadredmine-f5e5822945901bef9302315927d1a31ef8dd0ef4.tar.gz
redmine-f5e5822945901bef9302315927d1a31ef8dd0ef4.zip
Adds a 'sorted' scope to Project.
git-svn-id: http://svn.redmine.org/redmine/trunk@13541 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/projects_controller.rb')
-rw-r--r--app/controllers/projects_controller.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 9ab60a403..beb279476 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -40,21 +40,22 @@ class ProjectsController < ApplicationController
# Lists visible projects
def index
+ scope = Project.visible.sorted
+
respond_to do |format|
format.html {
- scope = Project
unless params[:closed]
scope = scope.active
end
- @projects = scope.visible.order('lft').to_a
+ @projects = scope.to_a
}
format.api {
@offset, @limit = api_offset_and_limit
- @project_count = Project.visible.count
- @projects = Project.visible.offset(@offset).limit(@limit).order('lft').to_a
+ @project_count = scope.count
+ @projects = scope.offset(@offset).limit(@limit).to_a
}
format.atom {
- projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).to_a
+ projects = scope.reorder(:created_on => :desc).limit(Setting.feeds_limit.to_i).to_a
render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
}
end