2012-06-07 68 views
4

我有一個運行ActiveAdmin並使用CarrierWave上傳圖片的ROR應用程序。我有一個模型:產品,它允許多個ProductImages。在添加新產品並選擇幾張圖片上傳時,所有這些似乎都很順利。但是,一旦我想修改該產品的形象似乎並沒有真正被上傳,再加上我得到以下錯誤:ROR + ActiveAdmin + Carrierwave,上傳多張圖片後編輯

​​

我的假設是,最初上傳並沒有做太多和爲此結束了空在編輯上。

這裏是管理形式的一個片段:

ActiveAdmin.register Product do 
    form(:html => {:multipart => true}) do |f| 
    f.inputs "Details" do 
     f.input :name 
     f.input :descr, :label => "Description" 
     f.input :brand, :as => :select, :collection => Brand.all, :member_label => :name, :label => "Brand" 

     # tags 
     f.autocomplete_field :tag_list, '/products/autocomplete_tag_name', :"data-delimiter" => ', ' 
     f.input :tag_list, :hint => "Comma delimited tags" 
    end 

    f.has_many :product_images do |pi| 
     pi.inputs "Product Images" do 
     if !pi.object.nil? 
      pi.input :_destroy, :as => :boolean, :label => 'Destroy?' 
     end 
     pi.input :image_name 
     pi.input :image 
     end 
    end 
    f.buttons 
    end 
end 

編輯

我知道一兩件事,圖像做得到上載創作的帖子,其從編輯行爲up ..

+1

我目前有同樣的問題 - 你找到任何解決方案嗎? :/ – mrmnmly

+0

同樣的問題...不能刪除後添加..任何運氣? – Danpe

回答

0

前段時間我有同樣的問題(但與Paperclip)。解決方案(不明顯)是如果用戶未在編輯表單中提供密碼以確認更新,則圖像未更新。

因此,如果您沒有嘗試此操作,可能值得:在編輯產品時要求用戶輸入密碼,然後查看圖像是否被正確更新。

+0

嗯。這聽起來是unistcary – Kasper

0

我最近遇到這個問題。 請更新您的表單字段,如下所示。您必須將輸入字段設置爲文件。

pi.input :image, :as => :file