DB: Integridade referencial

This commit is contained in:
2008-03-06 05:43:56 -03:00
parent e5bc6024ba
commit c58684c31c
12 changed files with 88 additions and 68 deletions

View File

@@ -25,14 +25,12 @@ class Attachment < ActiveRecord::Base
self.size = new_file.size
end
# Limpa o nome do arquivo
protected
def sanitize(filename)
filename = File.basename(filename)
filename.gsub(/[^\w\.\-]/, '_')
end
# Verifica se o arquivo é válido
def validate
if @tmp_file
errors.add("file") if @tmp_file.size == 0