Gotcha on the view thing. The file is not being changed - different file name. When I click update after selecting a different file, then go back in to view, it's the old file.
On Tuesday, November 27, 2012 11:38:36 AM UTC-8, Chris McCann wrote: > > I don't believe the file_field will show an existing attachment, which is > why you have the "View Attachment" link -- to indicate an existing > attachment. > > As for updating it, are you certain the file isn't being changed? Are you > using the same name for the new file? > > > On Tuesday, November 27, 2012 9:07:26 AM UTC-8, KT wrote: >> >> 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
