Is that possible to get the file name in Paperclip validation message?
I use Paperclip 2.3.11 in my Rails 3 application, and have the following validation:
validates_attachment_size :asset, :less_than => 2.megabytes,
开发者_StackOverflow中文版 :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
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" }
精彩评论