simple refactoring

This commit is contained in:
Andrey Kumanyaev 2012-10-09 04:10:04 +04:00
parent a635b9da97
commit df7c52489a
21 changed files with 276 additions and 264 deletions

View file

@ -6,16 +6,15 @@ class Key < ActiveRecord::Base
attr_accessible :key, :title
validates :title, presence: true, length: { within: 0..255 }
validates :key, presence: true,
length: { within: 0..5000 },
format: { :with => /ssh-.{3} / }
before_save :set_identifier
before_validation :strip_white_space
delegate :name, :email, to: :user, prefix: true
before_save :set_identifier
validates :title, presence: true, length: { within: 0..255 }
validates :key, presence: true, length: { within: 0..5000 }, format: { :with => /ssh-.{3} / }
validate :unique_key, :fingerprintable_key
delegate :name, :email, to: :user, prefix: true
def strip_white_space
self.key = self.key.strip unless self.key.blank?
end