diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-08-29 05:48:11 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-08-29 05:48:11 +0000 |
commit | 38ba617f99f2008f0ffbfc4dde26178581fabdd9 (patch) | |
tree | 84d74fff02a6226ef60b9e90a2b3e62dff36b314 /app | |
parent | 21e0fbb347f6bf529a087560571b11d885ac7b40 (diff) | |
download | redmine-38ba617f99f2008f0ffbfc4dde26178581fabdd9.tar.gz redmine-38ba617f99f2008f0ffbfc4dde26178581fabdd9.zip |
Rails3: replace deprecated 'validate_on_create' to declared validation method at Repository model.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6717 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/models/repository.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 21bf1fb5d..fc03bddb1 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -32,7 +32,13 @@ class Repository < ActiveRecord::Base validates_length_of :password, :maximum => 255, :allow_nil => true # Checks if the SCM is enabled when creating a repository - validate_on_create { |r| r.errors.add(:type, :invalid) unless Setting.enabled_scm.include?(r.class.name.demodulize) } + validate :repo_create_validation, :on => :create + + def repo_create_validation + unless Setting.enabled_scm.include?(self.class.name.demodulize) + errors.add(:type, :invalid) + end + end def self.human_attribute_name(attribute_key_name) attr_name = attribute_key_name |