0

I use Paperclip 2.3.11 in my Rails 3 application, and have the following validation:

validates_attachment_size :asset, :less_than => 2.megabytes, 
                          :message => "bigger than 2MB"

Is that possible to include the original file name in the message, so it will look like:

my_file.jpg bigger than 2MB
Misha Moroshko
  • 166,356
  • 226
  • 505
  • 746

1 Answers1

0

I think you ought to be able to pass in a lambda for :message, e.g.:

validates_attachment_size :asset, :less_than => 2.megabytes, 
                          :message => lambda {|asset| "#{asset.file_name} bigger than 2MB" }
Jordan Running
  • 102,619
  • 17
  • 182
  • 182