Anexos aninhados

This commit is contained in:
2009-09-06 21:00:20 -03:00
11 changed files with 108 additions and 27 deletions

View File

@@ -50,6 +50,8 @@ class Attachment < ActiveRecord::Base
# modificar a descrição, ou algo assim..
errors.add("file", "is needed"[]) if not self.id
end
errors.add("path", "muito longo") if !@path.nil? and @path.split('/').size > 10
end
# Salva o arquivo fisicamente no HD
@@ -70,4 +72,5 @@ class Attachment < ActiveRecord::Base
# @file_path = "#{RAILS_ROOT}/public/upload/#{course.id}/#{self.id}"
# File.delete(@file_path) if File.exists?(@file_path)
#end
end

View File

@@ -21,7 +21,7 @@ class Course < ActiveRecord::Base
# Associacoes
has_many :attachments,
:order => "file_name",
:order => "path, file_name",
:dependent => :destroy
has_many :events,