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
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
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs