#298 new
John Henderson

Webrat includes an empty file field as part of the fom submission

Reported by John Henderson | October 9th, 2009 @ 11:17 AM

Normally in a browser, when a form is submitted with an empty file input field, the file field is ignored and doesn't appear in the params hash. However, webrat doesn't conform to this rule. If a file field is empty, the params hash will still show an empty string for the uploaded data causing problems with nested attributes for example. It would great if this could be looked at in more detail.

Cheers

Comments and changes to this ticket

  • buzzware

    buzzware March 5th, 2010 @ 12:03 AM

    This might be trivial for some, but I've just spent a few hours trying to get my app to ignore this empty string. I'm using BrowserCMS, and for some reason the record won't create when this empty string is included. It works fine in real life. I'm still not sure what the answer is.

  • buzzware

    buzzware March 5th, 2010 @ 12:37 AM

    Here is a fix :

    Webrat::FileField.class_eval do

    alias_method :orig_to_param, :to_param
    def to_param(*args)
        return nil if value.nil?
        orig_to_param(*args)
    end
    

    end

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

People watching this ticket

Tags

Pages