# Filecolumn in Edit View - restful form - Update existing Image

**URL:** <https://www.ruby-forum.com/t/filecolumn-in-edit-view-restful-form-update-existing-image/126766>\
**Category:** Rails\
**Created:** [January 22, 2008, 1:11am UTC](https://www.ruby-forum.com/t/filecolumn-in-edit-view-restful-form-update-existing-image/126766 "2008-01-22T01:11:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bxsitecover](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/6a8cbe/32.png) [@bxsitecover](https://www.ruby-forum.com/u/bxsitecover)\
**Post date:** [January 22, 2008, 1:11am UTC](https://www.ruby-forum.com/t/filecolumn-in-edit-view-restful-form-update-existing-image/126766/1 "2008-01-22T01:11:35Z")

</div>

I generated code with ruby script/generate scaffold\_resource

Whenever I go to edit an image in filecolumn it creates a whole new  
record with the new image, as opposed to overwriting the image.

My Question is about the second block of code. How can I pass the ID  
so that I can update the record instead of creating a duplicate with a  
different image?

Here is my code.

Create View (works fine):

## New kellymadison

\<%= error\_messages\_for :km %\>

\<% form\_for(:km, :url =\> kms\_path,  
:html =\> { :multipart =\> true }) do |f| -%\>

Title: \<%= f.text\_field :title %\>

Description: \<%= f.text\_area :description %\>

URL for WMV: \<%= f.text\_field :wmv\_link %\>

URL for MOV: \<%= f.text\_field :mov\_link %\>

\<%= file\_column\_field "km", "image" %\>

\<%= submit\_tag 'Create' %\>

\<% end -%\>

\<%= link\_to image\_tag("/images/back.gif"), km\_path, :class =\> ‘back-  
btn’ %\>

Edit View (The VIEW I AM HAVING TROUBLE WITH. It creates a new record  
witha new ID)

## Edit km

\<%= error\_messages\_for :km %\>  
\<% form\_for(:km, :url =\> km\_path,  
:html =\> { :multipart =\> true }) do |f| -%\>

Title: \<%= f.text\_field :title %\>

Description: \<%= f.text\_area :description %\>

URL for WMV: \<%= f.text\_field :wmv\_link %\>

URL for MOV: \<%= f.text\_field :mov\_link %\>

\<% @km = Km.find(params[:id]) %\> \<%= file\_column\_field "km", "image" %\>

\<%= submit\_tag "Update" %\>

\<% end %\>

---

<div class="post-metadata">

**Author:** ![bxsitecover](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/6a8cbe/32.png) [@bxsitecover](https://www.ruby-forum.com/u/bxsitecover)\
**Post date:** [January 24, 2008, 4:00pm UTC](https://www.ruby-forum.com/t/filecolumn-in-edit-view-restful-form-update-existing-image/126766/2 "2008-01-24T16:00:17Z")

</div>

Please let me know if you find a solution.
