Skip to content

Instantly share code, notes, and snippets.

View ChristianPeters's full-sized avatar

Christian Peters ChristianPeters

View GitHub Profile
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