Custom validation with rails: words with more than 26 characters
1 2 def validate 3 if subject.split.any?{|w| w.length > 26} 4 errors.add(:subject, "cannot have words more than 26 consecutive characters") 5 end 6 end
DZone Snippets > ioda006 > on
13458 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
1 2 def validate 3 if subject.split.any?{|w| w.length > 26} 4 errors.add(:subject, "cannot have words more than 26 consecutive characters") 5 end 6 end