as my first project i am playing around with the swfupload ruby demo now i have run in a problem i dont get, maybe due to my lack of ror experience
what i want to do is, during upload, get the ids of the uploaded pics, put them in session[:new_photos] and then use this information in another view to tag all the newly uploaded pics
swfupload uploads the files to this, one file after another, so the swfupload method gets called multiple times for multiple files
def swfupload # swfupload action set in routes.rb
# The content_type is set as application/octet by the flash program # Use mimetype-fu to determine the mimetype before passing it # to the attachment_fu enabled model session[:new_photos] = session[:new_photos] || #<- i only did this after session[:new_photos] << @photo.id returned nil params[:Filedata].content_type = File.mime_type?(params[:Filedata].original_filename) @photo = Photo.new :uploaded_data => params[:Filedata] @photo.save! debugger session[:new_photos] << @photo.id debugger # This returns the thumbnail url for handlers.js to use to display the thumbnail render :text => @photo.public_filename(:thumb) rescue render :text => "Error" end
def x debugger @add_tags = Photo.find(session[:new_photos]) debugger render :action => "edit_multiple" end
after all files are uploaded i redirect to the x method which in turn renders the general method for adding tags
the strange thing i ran into is, that session is apparently only visible in the swfupload method, although i used it without problems in other places
when i tried to debug it first there was the problem that session[:new_photos] was nil in the swfupload method, so i tried to initialize it in the first run through, that worked, although i could not access it in the x method because it was nil again (during the debugging it was clearly filled with some ids in the swfupload method) so i guess the way i did it somehow makes session a local array with scope only for swfupload but i dont know how else to do it
any suggestions would be appreciated, tia, alex