diff app/controllers/documents_controller.rb @ 1298:4f746d8966dd redmine_2.3_integration

Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author Chris Cannam
date Fri, 14 Jun 2013 09:28:30 +0100
parents 622f24f53b42
children e248c7af89ec
line wrap: on
line diff
--- a/app/controllers/documents_controller.rb	Fri Jun 14 09:07:32 2013 +0100
+++ b/app/controllers/documents_controller.rb	Fri Jun 14 09:28:30 2013 +0100
@@ -1,5 +1,5 @@
 # Redmine - project management software
-# Copyright (C) 2006-2012  Jean-Philippe Lang
+# Copyright (C) 2006-2013  Jean-Philippe Lang
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -27,7 +27,7 @@
 
   def index
     @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
-    documents = @project.documents.find :all, :include => [:attachments, :category]
+    documents = @project.documents.includes(:attachments, :category).all
     case @sort_by
     when 'date'
       @grouped = documents.group_by {|d| d.updated_on.to_date }
@@ -43,7 +43,7 @@
   end
 
   def show
-    @attachments = @document.attachments.find(:all, :order => "created_on DESC")
+    @attachments = @document.attachments.all
   end
 
   def new
@@ -58,7 +58,7 @@
     if @document.save
       render_attachment_warning_if_needed(@document)
       flash[:notice] = l(:notice_successful_create)
-      redirect_to :action => 'index', :project_id => @project
+      redirect_to project_documents_path(@project)
     else
       render :action => 'new'
     end
@@ -71,7 +71,7 @@
     @document.safe_attributes = params[:document]
     if request.put? and @document.save
       flash[:notice] = l(:notice_successful_update)
-      redirect_to :action => 'show', :id => @document
+      redirect_to document_path(@document)
     else
       render :action => 'edit'
     end
@@ -79,7 +79,7 @@
 
   def destroy
     @document.destroy if request.delete?
-    redirect_to :controller => 'documents', :action => 'index', :project_id => @project
+    redirect_to project_documents_path(@project)
   end
 
   def add_attachment
@@ -89,6 +89,6 @@
     if attachments.present? && attachments[:files].present? && Setting.notified_events.include?('document_added')
       Mailer.attachments_added(attachments[:files]).deliver
     end
-    redirect_to :action => 'show', :id => @document
+    redirect_to document_path(@document)
   end
 end