minor: reogranized a bit code in platform model

This commit is contained in:
Timothy N. Tsvetkov 2011-03-10 13:45:38 +03:00
parent 3cbc1aeb78
commit 0363ad5cd7
1 changed files with 6 additions and 5 deletions

View File

@ -1,12 +1,13 @@
class Platform < ActiveRecord::Base class Platform < ActiveRecord::Base
validate :name, :presence => true, :uniqueness => true
validate :unixname, :presence => true, :uniqueness => true
before_validation :generate_unixname
validate :validate_unixname
has_many :projects, :dependent => :destroy has_many :projects, :dependent => :destroy
has_one :parent, :class_name => 'Platform', :foreign_key => 'parent_platform_id' has_one :parent, :class_name => 'Platform', :foreign_key => 'parent_platform_id'
validate :name, :presence => true, :uniqueness => true
validate :unixname, :presence => true, :uniqueness => true
validate :validate_unixname
before_validation :generate_unixname
protected protected
def generate_unixname def generate_unixname