Hi all I have the following method in a model: def validate if !@errors.on(:abbrevation) @errors.add(:abbrevation, self.class.error_messages[:not_allowed_chars_in_abbrevation]) unless abbrevation =~ /^[A-Z]+$/ end if !@errors.on(:abbrevation) @errors.add(:abbrevation, self.class.error_messages[:abbrevation_has_wrong_length]) unless abbrevation.length == 2 end end I repeat if !@errors.on(:abbrevation) 2 times and maybe will have to repeat it again in future when adding more validations. I''d really like to shorten this code, some sort of loop that runs as long as there is no error and in every loop another validation block is executed: while !@errors.on(:abbrevation) do # do some validation, and another validation, and another... end I guess I will have to use lambda or so, but I''m quite unsure how to use it appropriately in this case. Anyone has an idea? :-) Thanks Josh -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---