aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenare Degan <henare.degan@gmail.com>2015-05-20 15:54:16 +0200
committerHenare Degan <henare.degan@gmail.com>2015-05-20 15:54:16 +0200
commit226079e10290ddf1d22c43de283ce452d98b765d (patch)
tree7401a062a08bcd306ee77a00de88353cc86dbce2
parentda706b6c05ee7d0be15b59cf0fdec7f6d3ed58ec (diff)
Use built in validation on AboutMeValidator model
-rw-r--r--app/models/about_me_validator.rb11
1 files changed, 1 insertions, 10 deletions
diff --git a/app/models/about_me_validator.rb b/app/models/about_me_validator.rb
index ecca5d07d..a04db331b 100644
--- a/app/models/about_me_validator.rb
+++ b/app/models/about_me_validator.rb
@@ -10,20 +10,11 @@ class AboutMeValidator
attr_accessor :about_me
- # TODO: Switch to built in validations
- validate :length_of_about_me
+ validates_length_of :about_me, maximum: 500, message: _("Please keep it shorter than 500 characters")
def initialize(attributes = {})
attributes.each do |name, value|
send("#{name}=", value)
end
end
-
- private
-
- def length_of_about_me
- if !about_me.blank? && about_me.size > 500
- errors.add(:about_me, _("Please keep it shorter than 500 characters"))
- end
- end
end