]> source.dussan.org Git - redmine.git/commitdiff
Rails3: replace deprecated 'validate_on_create' to declared validation method at...
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Mon, 29 Aug 2011 05:48:11 +0000 (05:48 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Mon, 29 Aug 2011 05:48:11 +0000 (05:48 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6717 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/repository.rb

index 21bf1fb5dc607636070ae86bb62f44813c2b801e..fc03bddb1647d2a199cc6304a897071f1b2eb115 100644 (file)
@@ -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