Hi, there:
I wanna use plug-in "file_column" to upload image to the server. In
my test app, the view is as follow & it works well:
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.
Fred
Thanks, Frederick!
myst_tt wrote:
<h1>New entry</h1>
<%= error_messages_for 'entry' %>
<% form_tag 'create', :multipart => true do -%>
<p><label for="entry_image">Image</label><br/>
<%= file_column_field 'entry', 'image' %></p>
<%= submit_tag 'create' %>
<% end -%>
<%= link_to 'Back', entries_path %>
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.
- sappworks
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
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:
http://destiney.com/blog/rails-form-tag
-1 for failing to be a proper turd.