Dynamic Attachment Size for Paperclip (Rails)
Posted
by CalebHC
on Stack Overflow
See other posts from Stack Overflow
or by CalebHC
Published on 2010-04-27T22:19:53Z
Indexed on
2010/04/27
22:23 UTC
Read the original article
Hit count: 376
Is there anyway to have the validates_attachment_size except a dynamic file size limit? Here's an example:
class Document < ActiveRecord::Base
belongs_to :folder
has_attached_file :document
validates_attachment_size :document, :less_than => get_current_file_size_limit
private
def get_current_file_size_limit
10.megabytes # This will dynamically change
end
end
I've tried this but I keep getting an error saying "unknown method". Lambdas and Procs don't work either. Has anyone ever tried this? Thanks
© Stack Overflow or respective owner