Skip to content

Instantly share code, notes, and snippets.

@javan
Created August 26, 2014 16:02
Show Gist options
  • Save javan/a191389b710cd6f96eba to your computer and use it in GitHub Desktop.
Save javan/a191389b710cd6f96eba to your computer and use it in GitHub Desktop.
class Document < ActiveRecord::Base
columns.select { |c| c.limit && c.type.in?([:string, :text]) }.each do |column|
validates_length_of column.name, maximum: column.limit, tokenizer: ->(string) { string.bytes }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment