fix display of attachments with acts_as_journalized

This commit is contained in:
Tim Felgentreff 2010-08-04 18:56:33 +02:00
parent f45bb1e85e
commit cea1a987ab
1 changed files with 14 additions and 14 deletions

View File

@ -28,23 +28,23 @@ class Attachment < ActiveRecord::Base
acts_as_journalized :event_title => :filename,
:event_url => (Proc.new do |o|
{ :controller => 'attachments', :action => 'download',
:id => o.id, :filename => o.filename }
:id => o.versioned_id, :filename => o.filename }
end),
:activity_type => 'files',
:activity_permission => :view_files,
:activity_find_options => {:select => "#{Attachment.table_name}.*",
:joins => "LEFT JOIN #{Version.table_name} ON #{Version.table_name}.id = #{Attachment.table_name}.container_id " +
" AND #{Attachment.table_name}.container_type = 'Version' " +
"LEFT JOIN #{Project.table_name} ON #{Project.table_name}.id = #{Version.table_name}.project_id " +
" OR ( #{Attachment.table_name}.container_id = #{Project.table_name}.id " +
" AND #{Attachment.table_name}.container_type = 'Project' ) " }
:activity_permission => :view_files
acts_as_activity :type => 'documents',
:permission => :view_documents,
:find_options => {:select => "#{Attachment.table_name}.*",
:joins => "LEFT JOIN #{Document.table_name} ON (#{Document.table_name}.id = #{Attachment.table_name}.container_id" +
" AND #{Attachment.table_name}.container_type='Document') " +
"LEFT JOIN #{Project.table_name} ON (#{Project.table_name}.id = #{Document.table_name}.project_id)" }
acts_as_activity :type => 'documents', :permission => :view_documents
def activity_type
case container_type
when "Document"
"documents"
when "Version"
"files"
else
super
end
end
cattr_accessor :storage_path
@@storage_path = "#{RAILS_ROOT}/files"