Created
December 21, 2008 03:31
-
-
Save visnup/38554 to your computer and use it in GitHub Desktop.
validates_length_of_less_than_max_allowed_packet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.max_allowed_packet | |
r = connection.execute "SHOW GLOBAL VARIABLES LIKE 'max_allowed_packet'" | |
r.fetch_row.last.to_i rescue 128.megabytes | |
end | |
validates_length_of :data, :in => 1 .. max_allowed_packet, | |
:allow_blank => true | |
validates_length_of :file, :in => 1 .. max_allowed_packet, | |
:allow_blank => true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment