]> source.dussan.org Git - redmine.git/commitdiff
shorten long line of app/models/attachment.rb
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 22 Oct 2020 14:17:35 +0000 (14:17 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 22 Oct 2020 14:17:35 +0000 (14:17 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@20158 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/attachment.rb

index d6c272453c8d4ad94aaa451b0aa30185b917f912..3959a66677fc3b38323f87b10ef2d732b384455b 100644 (file)
@@ -32,26 +32,36 @@ class Attachment < ActiveRecord::Base
   validates_length_of :description, :maximum => 255
   validate :validate_max_file_size, :validate_file_extension
 
-  acts_as_event :title => :filename,
-                :url => Proc.new {|o| {:controller => 'attachments', :action => 'show', :id => o.id, :filename => o.filename}}
-
-  acts_as_activity_provider :type => 'files',
-                            :permission => :view_files,
-                            :author_key => :author_id,
-                            :scope => proc {
-                                      select("#{Attachment.table_name}.*").
-                                      joins("LEFT JOIN #{Version.table_name} ON #{Attachment.table_name}.container_type='Version' AND #{Version.table_name}.id = #{Attachment.table_name}.container_id " +
-                                            "LEFT JOIN #{Project.table_name} ON #{Version.table_name}.project_id = #{Project.table_name}.id OR ( #{Attachment.table_name}.container_type='Project' AND #{Attachment.table_name}.container_id = #{Project.table_name}.id )")
-                                      }
-
-  acts_as_activity_provider :type => 'documents',
-                            :permission => :view_documents,
-                            :author_key => :author_id,
-                            :scope => proc {
-                                      select("#{Attachment.table_name}.*").
-                                      joins("LEFT JOIN #{Document.table_name} ON #{Attachment.table_name}.container_type='Document' AND #{Document.table_name}.id = #{Attachment.table_name}.container_id " +
-                                            "LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id")
-                                      }
+  acts_as_event(
+    :title => :filename,
+    :url =>
+      Proc.new do |o|
+        {:controller => 'attachments', :action => 'show',
+         :id => o.id, :filename => o.filename}
+      end
+  )
+  acts_as_activity_provider(
+    :type => 'files',
+    :permission => :view_files,
+    :author_key => :author_id,
+    :scope =>
+      proc do
+        select("#{Attachment.table_name}.*").
+          joins("LEFT JOIN #{Version.table_name} ON #{Attachment.table_name}.container_type='Version' AND #{Version.table_name}.id = #{Attachment.table_name}.container_id " +
+                "LEFT JOIN #{Project.table_name} ON #{Version.table_name}.project_id = #{Project.table_name}.id OR ( #{Attachment.table_name}.container_type='Project' AND #{Attachment.table_name}.container_id = #{Project.table_name}.id )")
+      end
+  )
+  acts_as_activity_provider(
+    :type => 'documents',
+    :permission => :view_documents,
+    :author_key => :author_id,
+    :scope =>
+      proc do
+        select("#{Attachment.table_name}.*").
+          joins("LEFT JOIN #{Document.table_name} ON #{Attachment.table_name}.container_type='Document' AND #{Document.table_name}.id = #{Attachment.table_name}.container_id " +
+          "LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id")
+      end
+  )
 
   cattr_accessor :storage_path
   @@storage_path = Redmine::Configuration['attachments_storage_path'] || File.join(Rails.root, "files")