file_field is not sticky in my Rails form
Posted
by Tony
on Stack Overflow
See other posts from Stack Overflow
or by Tony
Published on 2010-06-10T03:47:18Z
Indexed on
2010/06/10
3:52 UTC
Read the original article
Hit count: 278
ruby-on-rails
|forms
I have a pretty standard Rails form:
<div>
<h1>Create a New Listing</h1>
<%- form_for @listing, :html => {:multipart => true} do |f| -%>
<div><%= f.label :title, "Title:"%> <%= f.text_field :title %></div>
<div>
<%= f.label :image, "Image:" %> <%= f.file_field :image
</div>
<div>
<%= f.label :sound, "Sound Clip:"%> <%= f.file_field :sound %><br />
</div>
<div class="submit"><%= f.submit 'Post Listing' %></div>
<%- end -%>
</div>
When a user chooses a file, but the form fails for validation purposes, he must always re-select the file. It is not sticky. Any suggestion on how to fix this?
Thanks!
© Stack Overflow or respective owner