diff options
author | spag <spag@golwen.net> | 2013-02-10 16:59:57 +0100 |
---|---|---|
committer | spag <spag@golwen.net> | 2013-02-10 16:59:57 +0100 |
commit | 70a6449fa176059e603a16a21699c8f5c60765e1 (patch) | |
tree | 5d6c74d2cd8d9e1c7b7c1a46a3a9972a757714b9 /app/models | |
parent | 33e88d16edc4d9f8047ef1a2087134c54f169c21 (diff) |
intruder updated
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/intruder.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/models/intruder.rb b/app/models/intruder.rb index 192d64d..c013ee8 100644 --- a/app/models/intruder.rb +++ b/app/models/intruder.rb @@ -1,3 +1,26 @@ class Intruder < ActiveRecord::Base attr_accessible :list_type, :key, :points, :bans, :ban_last, :ban_end, :contact_ip, :contact_port, :contact_count, :contact_last, :contacts_per_second, :contacts_per_second_max, :user_agent, :to_user, :comment + + LIST_TYPES = ['blacklist', 'whitelist'] + + validates :list_type, + :presence => true, + :inclusion => { :in => LIST_TYPES } + + validates :key, + :presence => true, + :uniqueness => true + + validates :contact_ip, + :presence => true, + :uniqueness => true + + before_validation :set_key_if_empty + + private + def set_key_if_empty + if self.key.blank? + self.key = self.contact_ip + end + end end |