aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2015-05-21 10:55:22 +0200
committerLouise Crow <louise.crow@gmail.com>2015-05-21 10:55:22 +0200
commit8ebdfc764098febaec07037f2a151e16cc71e47b (patch)
treeecb96ce6befaa4a4a676da68d3ad51b6091cfbaa
parente39e799ab42954f64595ad833c3dcd37e82fa1b2 (diff)
parent8fd1be6dcd444f737a96df3f7934261cfe9bb4e2 (diff)
Merge branch 'about-me-built-in-validation' into rails-3-develop
-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..8465b0716 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