From dc26a9cd39be4867dfc822cd4da019e478ff1a5f Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 8 Oct 2006 10:42:50 +0000 Subject: [PATCH] association loading in documents/show git-svn-id: http://redmine.rubyforge.org/svn/trunk@24 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- .../app/controllers/documents_controller.rb | 20 +++++++++---------- redmine/app/views/documents/show.rhtml | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/redmine/app/controllers/documents_controller.rb b/redmine/app/controllers/documents_controller.rb index e8c8e2d0..f2693577 100644 --- a/redmine/app/controllers/documents_controller.rb +++ b/redmine/app/controllers/documents_controller.rb @@ -16,10 +16,11 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class DocumentsController < ApplicationController - layout 'base' - before_filter :find_project, :authorize - - def show + layout 'base' + before_filter :find_project, :authorize + + def show + @attachments = @document.attachments.find(:all, :order => "created_on DESC") end def edit @@ -48,18 +49,17 @@ class DocumentsController < ApplicationController @attachment.author_id = self.logged_in_user.id if self.logged_in_user @attachment.save end - render :action => 'show' + redirect_to :action => 'show', :id => @document end def destroy_attachment @document.attachments.find(params[:attachment_id]).destroy - render :action => 'show' + redirect_to :action => 'show', :id => @document end private - def find_project + def find_project @document = Document.find(params[:id]) - @project = @document.project - end - + @project = @document.project + end end diff --git a/redmine/app/views/documents/show.rhtml b/redmine/app/views/documents/show.rhtml index 13662133..89693de8 100644 --- a/redmine/app/views/documents/show.rhtml +++ b/redmine/app/views/documents/show.rhtml @@ -18,11 +18,11 @@

- -<% for attachment in @document.attachments %> - +
+<% for attachment in @attachments %> + "> + -
<%= format_date(attachment.created_on) %> <%= link_to attachment.filename, :action => 'download', :id => @document, :attachment_id => attachment %><%= format_date(attachment.created_on) %> <%= attachment.author.display_name %> <%= human_size(attachment.filesize) %>
<%= lwr(:label_download, attachment.downloads) %>