I have an invoice model. When I create an invoice, an attachment is 
required. This works.

How can I replace the attachment during an update? I want the original 
attachment to be deleted. When I have the same form field on the edit 
screen, it does not update upon submission. The old file is still there. 
Also, it shows "no file chosen", even though there is one. I can click on 
View Attachment and it displays just fine.

invoice.rb

has_attached_file :attachment,
  :url => "http://...../attachments/:id/:style/:basename.:extension";,
  :path => ":rails_root/public/attachments/:id/:style/:basename.:extension"
  validates_attachment_presence :attachment
  validates_attachment_size :attachment, :less_than => 5.megabytes

_form.html.erb

<label>Invoice Attachment: </label><%= f.file_field :attachment %>
<%= link_to 'View Attachment', @invoice.attachment.url %>

-- 
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby

Reply via email to