Forum: Ruby on Rails file column validates_format_of

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
5cdb4ebd8d7d14ef89a33e813c89be9c?d=identicon&s=25 Rob B. (robtotheb)
on 2006-06-14 12:58
Been manually testing file column with success except it seems to upload
the file before validating it. Also .pdf files (which shouldn't even
validate) crash WEBrick.  What am I missing to solve these problems?
(apart from a brain!)

validates_presence_of :title, :file
validates_format_of :file, :with => %r{.(gif|jpg|png)$}i,
:message => "File must end with .jpg, .gif or .png"
file_column :file, :magick => {
      :versions => { "thumb" => "100x100", "medium" => "640x480>" }
    }

end
Brian Hogan (Guest)
on 2006-06-14 15:02
(Received via mailing list)
It's my understanding that file_column always uploads the file no matter
what.... it puts it in a temp location so that if there are errors on
any of
the other fields, your user won't need to upload the file again.
Therefore I
don't think you'll be able to do what you want to do in quite the way
you've
attempted.

A quick glance through the file_column docs shows that there is an
optional
parameter that allows you to set extensions, although its actual use is
not
documented.

Your crash is most likely caused because it can't resize a pdf with
RMagick
:)
This topic is locked and can not be replied to.