Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paperclip file size validation error message

validates_attachment_size :image, :less_than => 5.megabytes

gives an error message of

Image file size must be less than 5242880 Bytes

This isn't very user friendly.. Is there a way to make the message to be

Image file size must be less than 5 MB 

? without setting a custom message on my own

like image 838
Nick Ginanto Avatar asked Sep 05 '26 22:09

Nick Ginanto


1 Answers

Nope. You need to set a custom message to get that format. You can see from the paperclip source that they convert the size to an integer number of bytes in human_size.

like image 102
Andrew Haines Avatar answered Sep 07 '26 19:09

Andrew Haines



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!