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