Skip to content

Instantly share code, notes, and snippets.

@ChristianPeters
Created November 1, 2010 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChristianPeters/658820 to your computer and use it in GitHub Desktop.
Save ChristianPeters/658820 to your computer and use it in GitHub Desktop.
CHARACTER_LIMITS = { :description => 1000, :delivery_conditions_comment => 220, :terms_of_payment_comment => 200 }
validates_each CHARACTER_LIMITS.keys, :allow_nil => true do |record, attr, description|
record.errors.add attr, "zu lang (nicht mehr als #{CHARACTER_LIMITS[attr].to_s} Zeichen)." if attr_char_length(record[attr]) > CHARACTER_LIMITS[attr]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment