Thanks! I post all files together with paperclip and the jQuery file upload plugin.
I'll have a look at dragonfly! Thanks for the links! Arve Den 24. okt. 2012 kl. 19:50 skrev Vivek Sampara <[email protected]>: > Arve, > > There are multiple form posts happening. are you trying to post all the files > together or doing it from /new page multiple times ? > > If you are dealing with file types a lot, id suggest you to use dragonfly > gem. I have used it recently and its easier than paperclip . > > https://github.com/markevans/dragonfly > > and follow Florians advice here on multiple files in a single upload here > > http://stackoverflow.com/questions/7634869/multiple-image-upload-with-dragonfly > > Vivek > > On Wed, Oct 24, 2012 at 4:06 PM, Arve Voldsund <[email protected]> wrote: >> Hi Vivek, >> >> sure! >> >> The relationship: projectfile belongs_to project, project has_many >> projectfiles. >> >> This is the output when a "projectfile" is created: >> >> >> Started POST >> "/projectfiles?page_path=%2Fprojectfiles%2Fnew&authenticity_token=aPKvCdlOPVGREo%2BuFgJ3ryKgIdoEFm7%2F6XKoYj1WNxY%3D&projectfile%5Bname%5D=testProjectfile&projectfile%5Bproject_id%5D=3" >> for 127.0.0.1 at 2012-10-24 12:30:35 +0200 >> Processing by ProjectfilesController#create as JS >> Parameters: >> {"render"=>{"0"=>{"part_context"=>"BAhbCDoPc3RhdHVzX2JveEkiCXRoaXMGOgZFRlsA--9abff3e5dffdf3c9c358f90407a981ed82647623", >> "id"=>"status-box"}}, "page_path"=>"/projectfiles/new", >> "authenticity_token"=>"aPKvCdlOPVGREo+uFgJ3ryKgIdoEFm7/6XKoYj1WNxY=", >> "projectfile"=>{"name"=>"testProjectfile", "project_id"=>"3"}} >> User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? >> LIMIT 1 [["id", "1"]] >> (0.0ms) begin transaction >> SQL (0.4ms) INSERT INTO "projectfiles" ("created_at", "name", >> "prattach_content_type", "prattach_file_name", "prattach_file_size", >> "prattach_updated_at", "project_id", "updated_at") VALUES (?, ?, ?, ?, ?, ?, >> ?, ?) [["created_at", Wed, 24 Oct 2012 10:30:35 UTC +00:00], ["name", >> "testProjectfile"], ["prattach_content_type", nil], ["prattach_file_name", >> nil], ["prattach_file_size", nil], ["prattach_updated_at", nil], >> ["project_id", 3], ["updated_at", Wed, 24 Oct 2012 10:30:35 UTC +00:00]] >> [paperclip] Saving attachments. >> (52.1ms) commit transaction >> DRYML: Compiled app/views/projectfiles/new.dryml in 0.01s >> Call part: status_box. this-id = this, locals = [] >> Completed 200 OK in 75ms (Views: 0.1ms | ActiveRecord: 52.7ms) >> >> >> This is when files are uploaded from the "projectfile" edit-page: >> >> >> >> Started PUT >> "/projectfiles/11-testprojectfile?render[0][id]=image&render[0][part_context]=BAhbCToKaW1hZ2VJIhNwcm9qZWN0ZmlsZToxMQY6BkVGWwBbBkkiEHByb2plY3RmaWxlBjsGRg==--b6689878e7b1a69e638a6e6954162adff3eb293c" >> for 127.0.0.1 at 2012-10-24 12:34:14 +0200 >> >> >> Started PUT >> "/projectfiles/11-testprojectfile?render[0][id]=image&render[0][part_context]=BAhbCToKaW1hZ2VJIhNwcm9qZWN0ZmlsZToxMQY6BkVGWwBbBkkiEHByb2plY3RmaWxlBjsGRg==--b6689878e7b1a69e638a6e6954162adff3eb293c" >> for 127.0.0.1 at 2012-10-24 12:34:14 +0200 >> >> >> Started PUT >> "/projectfiles/11-testprojectfile?render[0][id]=image&render[0][part_context]=BAhbCToKaW1hZ2VJIhNwcm9qZWN0ZmlsZToxMQY6BkVGWwBbBkkiEHByb2plY3RmaWxlBjsGRg==--b6689878e7b1a69e638a6e6954162adff3eb293c" >> for 127.0.0.1 at 2012-10-24 12:34:14 +0200 >> Processing by ProjectfilesController#update as JS >> Parameters: {"page_path"=>"/projectfiles/11-testprojectfile/edit", >> "authenticity_token"=>"aPKvCdlOPVGREo+uFgJ3ryKgIdoEFm7/6XKoYj1WNxY=", >> "projectfile"=>{"prattach"=>#<ActionDispatch::Http::UploadedFile:0x007f852a533de0 >> @original_filename="togeterirute.png", @content_type="image/png", >> @headers="Content-Disposition: form-data; name=\"projectfile[prattach]\"; >> filename=\"togeterirute.png\"\r\nContent-Type: image/png\r\n", >> @tempfile=#<File:/var/folders/ww/z22b7qzd0cd7w55798byhhzm0000gn/T/RackMultipart20121024-29919-1xjd4ou>>}, >> "render"=>{"0"=>{"id"=>"image", >> "part_context"=>"BAhbCToKaW1hZ2VJIhNwcm9qZWN0ZmlsZToxMQY6BkVGWwBbBkkiEHByb2plY3RmaWxlBjsGRg==--b6689878e7b1a69e638a6e6954162adff3eb293c"}}, >> "id"=>"11-testprojectfile"} >> User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? >> LIMIT 1 [["id", "1"]] >> Projectfile Load (0.1ms) SELECT "projectfiles".* FROM "projectfiles" >> WHERE "projectfiles"."id" = ? LIMIT 1 [["id", "11-testprojectfile"]] >> Processing by ProjectfilesController#update as JS >> Parameters: {"page_path"=>"/projectfiles/11-testprojectfile/edit", >> "authenticity_token"=>"aPKvCdlOPVGREo+uFgJ3ryKgIdoEFm7/6XKoYj1WNxY=", >> "projectfile"=>{"prattach"=>#<ActionDispatch::Http::UploadedFile:0x007f852eddc218 >> @original_filename="QR.png", @content_type="image/png", >> @headers="Content-Disposition: form-data; name=\"projectfile[prattach]\"; >> filename=\"QR.png\"\r\nContent-Type: image/png\r\n", >> @tempfile=#<File:/var/folders/ww/z22b7qzd0cd7w55798byhhzm0000gn/T/RackMultipart20121024-29924-lnxop8>>}, >> "render"=>{"0"=>{"id"=>"image", >> "part_context"=>"BAhbCToKaW1hZ2VJIhNwcm9qZWN0ZmlsZToxMQY6BkVGWwBbBkkiEHByb2plY3RmaWxlBjsGRg==--b6689878e7b1a69e638a6e6954162adff3eb293c"}}, >> "id"=>"11-testprojectfile"} >> User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? >> LIMIT 1 [["id", "1"]] >> Projectfile Load (0.1ms) SELECT "projectfiles".* FROM "projectfiles" >> WHERE "projectfiles"."id" = ? LIMIT 1 [["id", "11-testprojectfile"]] >> Command :: identify -format %wx%h :file >> Command :: identify -format %wx%h :file >> Processing by ProjectfilesController#update as JS >> Parameters: {"page_path"=>"/projectfiles/11-testprojectfile/edit", >> "authenticity_token"=>"aPKvCdlOPVGREo+uFgJ3ryKgIdoEFm7/6XKoYj1WNxY=", >> "projectfile"=>{"prattach"=>#<ActionDispatch::Http::UploadedFile:0x007f852b50d270 >> @original_filename="IMG_4260.jpg", @content_type="image/jpeg", >> @headers="Content-Disposition: form-data; name=\"projectfile[prattach]\"; >> filename=\"IMG_4260.jpg\"\r\nContent-Type: image/jpeg\r\n", >> @tempfile=#<File:/var/folders/ww/z22b7qzd0cd7w55798byhhzm0000gn/T/RackMultipart20121024-29926-h35lak>>}, >> "render"=>{"0"=>{"id"=>"image", >> "part_context"=>"BAhbCToKaW1hZ2VJIhNwcm9qZWN0ZmlsZToxMQY6BkVGWwBbBkkiEHByb2plY3RmaWxlBjsGRg==--b6689878e7b1a69e638a6e6954162adff3eb293c"}}, >> "id"=>"11-testprojectfile"} >> User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? >> LIMIT 1 [["id", "1"]] >> Projectfile Load (0.1ms) SELECT "projectfiles".* FROM "projectfiles" >> WHERE "projectfiles"."id" = ? LIMIT 1 [["id", "11-testprojectfile"]] >> Command :: identify -format %wx%h :file >> Command :: convert :source -auto-orient -resize "x138" -crop "200x138+19+0" >> +repage :dest >> Command :: convert :source -auto-orient -resize "x138" -crop "200x138+29+0" >> +repage :dest >> Command :: convert :source -auto-orient -resize "200x" -crop "200x138+0+31" >> +repage :dest >> Command :: identify -format %wx%h :file >> Command :: convert :source -auto-orient -resize "100x100>" :dest >> Command :: identify -format %wx%h :file >> Command :: convert :source -auto-orient -resize "100x100>" :dest >> Command :: identify -format %wx%h :file >> (0.2ms) begin transaction >> (0.4ms) UPDATE "projectfiles" SET "prattach_file_name" = 'QR.png', >> "prattach_file_size" = 192785, "prattach_updated_at" = '2012-10-24 >> 10:34:14.981083', "updated_at" = '2012-10-24 10:34:15.153576' WHERE >> "projectfiles"."id" = 11 >> [paperclip] Saving attachments. >> [paperclip] deleting lib/prattach/original/togeterirute.png >> [paperclip] deleting lib/prattach/medium/togeterirute.png >> [paperclip] deleting lib/prattach/thumb/togeterirute.png >> (2.5ms) commit transaction >> Command :: convert :source -auto-orient -resize "100x100>" :dest >> Call part: image. this-id = projectfile:11, locals = [] >> : form_field_path = ["projectfile"] >> Completed 200 OK in 203ms (Views: 0.3ms | ActiveRecord: 3.4ms) >> (0.2ms) begin transaction >> (0.4ms) UPDATE "projectfiles" SET "prattach_file_name" = 'IMG_4260.jpg', >> "prattach_content_type" = 'image/jpeg', "prattach_file_size" = 98787, >> "prattach_updated_at" = '2012-10-24 10:34:15.000437', "updated_at" = >> '2012-10-24 10:34:15.195829' WHERE "projectfiles"."id" = 11 >> [paperclip] Saving attachments. >> [paperclip] deleting lib/prattach/original/togeterirute.png >> [paperclip] deleting lib/prattach/medium/togeterirute.png >> [paperclip] deleting lib/prattach/thumb/togeterirute.png >> (2.3ms) commit transaction >> (0.2ms) begin transaction >> Call part: image. this-id = projectfile:11, locals = [] >> : form_field_path = ["projectfile"] >> (0.5ms) UPDATE "projectfiles" SET "prattach_updated_at" = '2012-10-24 >> 10:34:14.978709', "updated_at" = '2012-10-24 10:34:15.212436' WHERE >> "projectfiles"."id" = 11 >> [paperclip] Saving attachments. >> [paperclip] deleting lib/prattach/original/togeterirute.png >> [paperclip] deleting lib/prattach/medium/togeterirute.png >> Completed 200 OK in 231ms (Views: 0.3ms | ActiveRecord: 3.2ms) >> [paperclip] deleting lib/prattach/thumb/togeterirute.png >> (2.5ms) commit transaction >> DRYML: Compiled app/views/projectfiles/edit.dryml in 0.03s >> Call part: image. this-id = projectfile:11, locals = [] >> : form_field_path = ["projectfile"] >> Completed 200 OK in 293ms (Views: 0.2ms | ActiveRecord: 3.5ms) >> >> >> >> >> kl. 03:49:12 UTC+2 onsdag 24. oktober 2012 skrev Vivek Sampara følgende: >>> >>> Arve, >>> >>> Can you show your params results( console ) here you get after clicking >>> create button ? and what is the association you specified in the >>> projectfile and Project Model ? >>> >>> Vivek >>> >>> On Wed, Oct 24, 2012 at 3:52 AM, Arve Voldsund <[email protected]> wrote: >>>> I struggle a bit with a create method for a model with multiple file >>>> upload, and could really need some advice on this. >>>> >>>> Basically I want the user to create a new projectfile (that's the model >>>> name) and assign it to a project. This is trivial. >>>> >>>> Then, in the edit-page for that particular projectfile there is a file >>>> upload using the jQuery file upload plugin which allows multiple files. >>>> Files upload just fine, but only one file will be assigned to the >>>> projectfile in the database. I understand why, but I do not quite get how >>>> to fix it in the create method. >>>> >>>> >>>> Arve >>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google Groups >>>> "Hobo Users" group. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msg/hobousers/-/9skhe0yG4hUJ. >>>> To post to this group, send email to [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]. >>>> >>>> For more options, visit this group at >>>> http://groups.google.com/group/hobousers?hl=en. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Hobo Users" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/hobousers/-/n_ITLJzDsbwJ. >> >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/hobousers?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Hobo Users" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/hobousers?hl=en. -- You received this message because you are subscribed to the Google Groups "Hobo Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.
