I have been trying to create a multi-part form in Rails for the last day, which is crazy, but I am really not sure how to get around this one.
Currently, here is the code in my view:
<%= form_for @account, :html => {:multipart => true } do |f| %>
However, the HTML returned is as follows:
<form accept-charset="UTF-8" action="/accounts/1" class="edit_account" id="edit_account_1" method="post">
For the life of me I can't figure out why the form is not showing up as a multi-part. This particular form is used to upload an image using paperclip to AWS, but fails each time, presumably because it isn't a multipart form.
Help! :) And thanks.
This worked for me.
or
As per @peterpengnz's answer, providing an empty
{}
parameter toform_for
got ArgumentError:Hi according to Rails API v3.1.3, your code should look like following:
The difference is by passing empty options to rails helper and it will read your html parameters.
Thanks
UPDATE:
Here is the code copied from one of my projects: It is working and runs under Rails 3.1
May be you could try to put brackets after the "form_for"
It turns out that I'm a huge idiot, and the original form was working fine, EXCEPT...
I was rendering the form in a partial, but I wrapped the partial in a standard, non-multipart form tag, which overwrote the multipart form, and somewhat surprisingly didn't raise any errors.
Either way, I am a stupid one for not noticing this, but it is now resolved and the file uploading is working perfectly.