File_column not keeping value during page reloads

I’m trying to use the file_column plug-in to attach a file to a
newsletter posting. It works fine if I get the form right the first
time, but if I get an error, such as not typing in a required field, and
the form re-displays, my file selection box reverts to “no file
selected.”

Here’s my relevant controller code:

def new
@newsletterpost = Newsletterpost.new
end

def add_post
@newsletterpost = Newsletterpost.new(params[:newsletterpost])
@newsletterpost.user_id = @session[:user].id
if @newsletterpost.save
flash[:notice] = “Newsletter posting was successfully
created.”
redirect_to :action => ‘list’
else
render :action => ‘new’
end
end

And the relevant section from my _form.rhtml file:

<label for='newsletterpost_filename'>Attachment:</label><br/>
<%= file_column_field 'newsletterpost', 'filename' %> <br /><br />

And my newsletterpost model:

class Newsletterpost < ActiveRecord::Base
belongs_to :user
belongs_to :newslettercategory
file_column :filename
validates_presence_of :title
end

Any suggestions? Thanks!!

On 1/22/06, Dylan M. [email protected] wrote:

file_column :filename

The file is prolly just being stored in the filename hidden field. I
have found it useful to add some sort of notice beneath the
file_column_field to tell the user what is currently stored, because
the file_column_field definitely doesn’t do that. Something like:

<%=File.basename(@model.filename.to_s)%>


Kyle M.
Chief Technologist
E Factor Media // FN Interactive
[email protected]
1-866-263-3261

On 1/22/06, Dylan M. [email protected] wrote:

I’m trying to use the file_column plug-in to attach a file to a
newsletter posting. It works fine if I get the form right the first
time, but if I get an error, such as not typing in a required field, and
the form re-displays, my file selection box reverts to “no file selected.”

you can’t do anything against this as pre-filling a file selection box
with a custom value would create quite a security issue. So you have
to create your own indication that a file has been uploaded, as Kyle
suggested.

Sebastian