Commit cea1a987 authored by Tim Felgentreff's avatar Tim Felgentreff

fix display of attachments with acts_as_journalized

parent f45bb1e8
......@@ -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"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment