shorten long line of app/models/document.rb

git-svn-id: http://svn.redmine.org/redmine/trunk@20162 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA
2020-10-22 14:18:06 +00:00
parent ba8a8dede3
commit bb449e202e

View File

@@ -26,10 +26,19 @@ class Document < ActiveRecord::Base
acts_as_searchable :columns => ['title', "#{table_name}.description"],
:preload => :project
acts_as_event :title => Proc.new {|o| "#{l(:label_document)}: #{o.title}"},
:author => Proc.new {|o| o.attachments.reorder("#{Attachment.table_name}.created_on ASC").first.try(:author) },
:url => Proc.new {|o| {:controller => 'documents', :action => 'show', :id => o.id}}
acts_as_activity_provider :scope => proc { preload(:project) }
acts_as_event(
:title => Proc.new {|o| "#{l(:label_document)}: #{o.title}"},
:author =>
Proc.new do |o|
o.attachments.reorder("#{Attachment.table_name}.created_on ASC").
first.try(:author)
end,
:url =>
Proc.new do |o|
{:controller => 'documents', :action => 'show', :id => o.id}
end
)
acts_as_activity_provider :scope => proc {preload(:project)}
validates_presence_of :project, :title, :category
validates_length_of :title, :maximum => 255