bxsitecover
2008-Jan-22 00:10 UTC
Filecolumn in Edit View - restful form - Update existing Image
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):
<h2>New kellymadison</h2>
<%= error_messages_for :km %>
<% form_for(:km, :url => kms_path,
:html => { :multipart => true }) do |f| -%>
<p>
<label for="Title">Title:</label>
<%= f.text_field :title %>
</p>
<p>
<label for="Description">Description:</label>
<%= f.text_area :description %>
</p>
<p>
<label for="wmv">URL for WMV:</label>
<%= f.text_field :wmv_link %>
</p>
<p>
<label for="wmv">URL for MOV:</label>
<%= f.text_field :mov_link %>
</p>
<p>
<%= file_column_field "km", "image" %>
</p>
<p>
<%= submit_tag ''Create'' %>
</p>
<% 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)
<h2>Edit km</h2>
<%= error_messages_for :km %>
<% form_for(:km, :url => km_path,
:html => { :multipart => true }) do |f| -%>
<p>
<label for="Title">Title:</label>
<%= f.text_field :title %>
</p>
<p>
<label for="Description">Description:</label>
<%= f.text_area :description %>
</p>
<p>
<label for="wmv">URL for WMV:</label>
<%= f.text_field :wmv_link %>
</p>
<p>
<label for="wmv">URL for MOV:</label>
<%= f.text_field :mov_link %>
</p>
<p>
<% @km = Km.find(params[:id]) %>
<%= file_column_field "km", "image" %>
</p>
<p>
<%= submit_tag "Update" %>
</p>
<% end %>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Mario Flores
2008-Jan-24 15:00 UTC
Re: Filecolumn in Edit View - restful form - Update existing
Please let me know if you find a solution. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---