Not recieving ID for update action

I'm trying to create an edit page that will redirect back to the edit page after an update, but what I'm finding is that the update action isn't getting the :id back, and errors out. Any thoughts or hints?

def edit @listing = Listing.find(params[:id]) @listing.photos = Photo.find(:all ) end

def update   @listing = Listing.find(params[:id]) #ERROR OCCURS HERE   ..... end

edit.rhtml: <%= form_tag ({:action => 'update'}, {:id => @listing}, {:multipart => true} ) %>   <%= render :partial => 'form' %>   <%= submit_tag 'Edit' %> <%= end_form_tag %>

_form.rhtml: <p><label for="listing_status">Status</label><br/> <%= text_field 'listing', 'status' %></p>

<% @listing.photos.each do |image| %> <%= image_tag url_for(:action => 'image', :id => image) %> <% end %>

<p> <label for="photo_path">Photo Name: </label><br/> <%= file_field("image", "data") %> </p>

Ultimately what I'm trying to do is to be able to upload multiple files, but redirecting to the edit page to add one more, while listing the ones that are already loaded.

Thanks, Matt

Hi Matt,

matt wrote:

I'm trying to create an edit page that will redirect back to the edit page after an update, <snip> edit.rhtml: <%= form_tag ({:action => 'update'}, {:id => @listing}, {:multipart => true} ) %>

Try: <%= form_tag({action => 'update', :id => @listing}, :multipart => true) %>

I think you can exclude the braces (ie., {}), but I'm not sure and don't have time to test it right now.

hth, Bill

Thanks, That got me into my update method with an :id.