Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails file_field_tag not uploading file

I have a form:

<%= form_tag :controller => "foo", :action => "boo", :multipart => true do %>
    <%= file_field_tag "foo[bar]" %>
<% end %>

When I submit it, the param foo[bar] gives "foo[bar]"=>"filename.png" instead of an ActionDispatch object.

Anybody have any clues what might be the cause here?

Thanks!

like image 809
gtr32x Avatar asked Jan 10 '13 04:01

gtr32x


1 Answers

Solved. Needed to change the form_tag line to:

<%= form_tag ({:controller => "foo", :action => "boo"}), :enctype =>"multipart/form-data" do %>
    <%= file_field_tag "foo[bar]" %>
<% end %>
like image 84
gtr32x Avatar answered Nov 03 '22 06:11

gtr32x