2014-09-20 51 views
1

我有軌道4 + CarrierWave +嵌套形式Ad模型,許多Image(安裝PictureUploaderpicture未經許可參數上傳

當我嘗試添加或編輯Ad,我有未經許可的參數picture

Parameters: {"utf8"=>"✓", 
"ad"=>{ 
    "title"=>"plot", 
    "images_attributes"=> 
     { "0" => 
     { 
      "picture"=>[#<ActionDispatch::Http::UploadedFile:0x007fbea1ddedb8 @tempfile=#<Tempfile:/var/folders/t8/fm77jh7j6232v5km2llkgq1r0000gn/T/RackMultipart20140921-33609-54hs6k>, @original_filename="New-york-rental-apartment-1-.gif", @content_type="image/gif", @headers="Content-Disposition: form-data; name=\"ad[images_attributes][0][picture][]\"; filename=\"New-york-rental-apartment-1-.gif\"\r\nContent-Type: image/gif\r\n">], 
      "_destroy"=>"false" 
     } 
     } 
    } 
} 

Unpermitted parameters: parent_id 
Unpermitted parameters: parent_id 
Unpermitted parameters: picture 

我允許以下參數。 (根據this Rails Guide,我的代碼應該是工作)

params.require(:ad).permit(:picture, :title, :images_attributes => [:picture, :id, :_destroy]) 

我只能從carrierwave後備圖片,現在我無言以對。

EDIT 1:

實測值在github this issue討論約Carrierwave不與嵌套形式工作。

也找到A complete sample of how to perform nested polymorphic uploads in rails using carrierwave。這是在Rails 3中,我還沒有測試過。

回答