From 4333fac4659bd3aa0d23587f27c2b673694472c7 Mon Sep 17 00:00:00 2001 From: "vit.jonas@gmail.com" Date: Tue, 24 May 2011 20:04:29 +0000 Subject: [PATCH] * small fixes to file validation git-svn-id: http://redmine-dmsf.googlecode.com/svn/trunk/redmine_dmsf@79 5e329b0b-a2ee-ea63-e329-299493fc886d --- app/controllers/dmsf_detail_controller.rb | 3 ++- app/models/dmsf_file.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/dmsf_detail_controller.rb b/app/controllers/dmsf_detail_controller.rb index 40b5d26c..2338377b 100644 --- a/app/controllers/dmsf_detail_controller.rb +++ b/app/controllers/dmsf_detail_controller.rb @@ -129,7 +129,8 @@ class DmsfDetailController < ApplicationController @file.name = @revision.name @file.folder = @revision.folder - if @revision.save && @file.valid? + if @revision.valid? && @file.valid? + @revision.save! unless file_upload.nil? @revision.copy_file_content(file_upload) end diff --git a/app/models/dmsf_file.rb b/app/models/dmsf_file.rb index 39dc566a..45cfb298 100644 --- a/app/models/dmsf_file.rb +++ b/app/models/dmsf_file.rb @@ -43,7 +43,7 @@ class DmsfFile < ActiveRecord::Base def validates_name_uniqueness existing_file = DmsfFile.find_file_by_name(self.project, self.folder, self.name) - errors.add(:name, "has already been taken") unless + errors.add(:name, l("activerecord.errors.messages.taken")) unless existing_file.nil? || existing_file.id == self.id end