Multipart form with empty file_field submits nil

33 views
Skip to first unread message

Trevor Turk

unread,
Mar 13, 2009, 3:14:14 AM3/13/09
to Rack Development
I'm cross posting about an issue that impacting the Paperclip plugin
for Rails. To quote the issue:

"I noticed that posting a multipart form with a blank file_field
submits a nil in edge rails. Is this the intended behavior? In rails
2.2 it submitted an empty string.

I'm using the paperclip plugin which ignores the empty string but
deletes attachments that are set to nil. With this new behavior,
paperclip deletes every attachment on update. If this is the intended
behavior for rails 2.3 then I'll submit a ticket on the paperclip
project about modifying the plugin to handle nil values a different
way."

I posted a patch here:

http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1945-multipart-form-with-empty-file_field-submits-nil

The idea solution may be to ignore empty file_field submissions, but I
could only figure out how to submit "" instead of nil. Maybe someone
would like to give it another shot. If not, this seems to alleviate
the immediate concern, at least.

Thanks,
- Trevor

rob-twf

unread,
Mar 13, 2009, 5:21:26 AM3/13/09
to Rack Development
Just a quick note to say I've posted a slightly different patch here:
http://rack.lighthouseapp.com/projects/22435/tickets/37-remove-files-from-params-when-no-file-selected

This one discards empty file params instead of setting them to nil.


On Mar 13, 7:14 am, Trevor Turk <trevort...@gmail.com> wrote:
> I'm cross posting about an issue that impacting the Paperclip plugin
> for Rails. To quote the issue:
>
> "I noticed that posting a multipart form with a blank file_field
> submits a nil in edge rails. Is this the intended behavior? In rails
> 2.2 it submitted an empty string.
>
> I'm using the paperclip plugin which ignores the empty string but
> deletes attachments that are set to nil. With this new behavior,
> paperclip deletes every attachment on update. If this is the intended
> behavior for rails 2.3 then I'll submit a ticket on the paperclip
> project about modifying the plugin to handle nil values a different
> way."
>
> I posted a patch here:
>
> http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/19...
Reply all
Reply to author
Forward
0 new messages