##// END OF EJS Templates
association loading in documents/show...
Jean-Philippe Lang -
r22:dc26a9cd39be
parent child
Show More
@@ -20,6 +20,7 class DocumentsController < ApplicationController
20 before_filter :find_project, :authorize
20 before_filter :find_project, :authorize
21
21
22 def show
22 def show
23 @attachments = @document.attachments.find(:all, :order => "created_on DESC")
23 end
24 end
24
25
25 def edit
26 def edit
@@ -48,12 +49,12 class DocumentsController < ApplicationController
48 @attachment.author_id = self.logged_in_user.id if self.logged_in_user
49 @attachment.author_id = self.logged_in_user.id if self.logged_in_user
49 @attachment.save
50 @attachment.save
50 end
51 end
51 render :action => 'show'
52 redirect_to :action => 'show', :id => @document
52 end
53 end
53
54
54 def destroy_attachment
55 def destroy_attachment
55 @document.attachments.find(params[:attachment_id]).destroy
56 @document.attachments.find(params[:attachment_id]).destroy
56 render :action => 'show'
57 redirect_to :action => 'show', :id => @document
57 end
58 end
58
59
59 private
60 private
@@ -61,5 +62,4 private
61 @document = Document.find(params[:id])
62 @document = Document.find(params[:id])
62 @project = @document.project
63 @project = @document.project
63 end
64 end
64
65 end
65 end
@@ -18,11 +18,11
18
18
19 <br /><br />
19 <br /><br />
20
20
21 <table border="0" cellspacing="1" cellpadding="2" width="100%">
21 <table class="listTableContent">
22 <% for attachment in @document.attachments %>
22 <% for attachment in @attachments %>
23 <tr style="background-color:#CEE1ED">
23 <tr class="<%= cycle("odd", "even") %>">
24 <td><%= format_date(attachment.created_on) %></td>
24 <td><%= link_to attachment.filename, :action => 'download', :id => @document, :attachment_id => attachment %></td>
25 <td><%= link_to attachment.filename, :action => 'download', :id => @document, :attachment_id => attachment %></td>
25 <td align="center"><%= format_date(attachment.created_on) %></td>
26 <td align="center"><%= attachment.author.display_name %></td>
26 <td align="center"><%= attachment.author.display_name %></td>
27 <td><%= human_size(attachment.filesize) %><br /><%= lwr(:label_download, attachment.downloads) %></td>
27 <td><%= human_size(attachment.filesize) %><br /><%= lwr(:label_download, attachment.downloads) %></td>
28
28
General Comments 0
You need to be logged in to leave comments. Login now