protected
def validate
errors.add("imagefile", "Must be a valid file.") unless
imagefile.respond_to? :read
end
Haven''t tested this, try this out tho.
Vish
On 9/28/06, Robert Spielmann
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
>
> Hi,
>
> I tried to validate a file input form field using validates_presence_of
> :imagefile, which seems to always return true. How can I validate that
> the user has chosen a file to upload?
>
> thx
> Robert
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---