Im利用承运人wave将照片上载到世界模型。 我似乎无法得到上载表格:
class World
include Mongoid::Document
embeds_many :photos
accepts_nested_attributes_for :photos
end
class Photo
include Mongoid::Document
mount_uploader :image, WorldPhotoUploader
embedded_in :world
end
# show.haml
= form_for world, :html => {:multipart => true} do |f|
= f.fields_for world.photos.build do |photo|
= photo.file_field :image
这为我提供了这种形式的投入:
<input id="world_photo_image" name="world[photo][image]" type="file">
哪怕是工作,我就找了。
Cannot serialize an object of class ActionDispatch::Http::UploadedFile into BSON.
{"utf8"=>"✓",
"_method"=>"put",
"authenticity_token"=>"e2PzZlSY0NwiCqDWn7ZMNwqnypP+GC23PcMuy+uGyF0=",
"world"=>{"photo"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x00000103182ac8 @original_filename="Black Box fish.jpg",
@content_type="image/jpeg",
@headers="Content-Disposition: form-data; name="world[photo][image]"; filename="Black Box fish.jpg"
Content-Type: image/jpeg
",
@tempfile=#<File:/var/folders/IY/IY7PGAf2F9OD6CIKr1RQo++++TI/-Tmp-/RackMultipart20110917-57084-zwoyfy>>}},
"commit"=>"Upload",
"id"=>"pluto"}
看来行之有效的投入是:
<input id="world_photo_image" name="world[photos][][image]" type="file">
但是,我不敢确定如何创造实现这一目的的形式。