However, in my real app, I scaffold and nest the resource to
RESTful, the view is as follow & it errors: “Do not know how to handle
a string with value ‘readme.jpg’ that was passed to a file_column.
Check if the form’s encoding has been set to ‘multipart/form-data’”
======================
<% form_for([@task, @comment]) do |f| %>
Comment body
<%= f.text_area :desc %>
Image
<%= file_column_field 'comment', 'image' %>
<%= f.submit button_name %>
<% end %>
======================
I checked the API doc, but seems like "form_for" does not support
option “:multipart => true”, what should I do here? Anyone could
explain me what’s differ between “form_for” & “form_tag” ??
I checked the API doc, but seems like “form_for” does not support
option “:multipart => true”, what should I do here? Anyone could
explain me what’s differ between “form_for” & “form_tag” ??
It does, just pass it as the html options, ie
form_for :person, @person, :html => {:multipart => true}
The api docs on form_for are a good starting point from the difference
with form_tag.
Ben,
I don’t mean to be a ‘turd’ here, but that won’t work. Here is what it
should look like:
<%= form_tag(:url => {:action=> “create” }, :html => { :multipart =>
true }) -%>
Kathleen
Ran into this issue just now when moving from old rails version to
2.0.2.
If you want to use form_tag instead of form_for, you must group your
action and controller hash with brackets like this:
form_tag( {:action => ‘create’}, :multipart => true ) do
Otherwise if you indicate :action with no brackets, it then thinks that
all of your parameters belong in the same hash with :action,
:controller, :params, etc. and puts everything you specify right into
the querystring. I think the above would also work without parentheses.
I don’t mean to be a ‘turd’ here, but that won’t work. Here is what it
should look like:
<%= form_tag(:url => {:action=> “create” }, :html => { :multipart =>
true }) -%>
Rails already knows/expects the first hash will be the :url hash and
the second hash the :html.
form_tag( {:action => ‘create’}, :multipart => true ) do
I, like Ben, have long prefered the perfectly acceptable (shorter)
version you choose to criticize: