i'm公認編輯模型時,特別是當我刪除與之關聯的圖像得到這個錯誤,我選擇另一:回形針:: NotIdentifiedByImageMagickError圖像不被「識別」命令
Paperclip::NotIdentifiedByImageMagickError in Admin/packsController#update
Chrysanthemumprueba4.jpg is not recognized by the 'identify' command.
C:/Users/.../vendor/plugins/thoughtbot-paperclip-fc792c8/lib/paperclip/geometry.rb:24:in `from_file'
但是,當我創建一個新的包,我選擇它的圖像,它工作正常。
我有兩個表:包和pack_images,並pack_images有照片爲相關的包裝,這裏有關係:
class Pack < ActiveRecord::Base
has_many :pack_images, :dependent => :destroy
end
class PackImage < ActiveRecord::Base
belongs_to :pack
attr_accessor :height, :width
has_attached_file :photo, :url => "/:attachment/:class/:id/:style_:basename.:extension", :styles => {:principal => "240x240>", :original => "400x400>", ...}
end
這是控制器的動作拋出我的錯誤:
def update
@pack = Pack.find(params[:id])
@pack.pack_products
unless params[:pack][:pack_images_attributes].nil?
params[:pack][:pack_images_attributes].count.times do |i|
unless params[:pack][:pack_images_attributes][:"#{i.to_s}"][:photo].blank?
file = params[:pack][:pack_images_attributes][:"#{i.to_s}"][:photo]
dimensions = Paperclip::Geometry.from_file(file)
@pack.pack_images[i].width = dimensions.width
@pack.pack_images[i].height = dimensions.height
end
end
end
respond_to do |format|
@pack.update_attributes(params[:pack])
format.html { redirect_to(admin_pack_path(@pack.id), :notice => 'Pack updated') }
end
我注意到,在更新時,我比創建時(照片的名稱,文件類型,寬度,高度等)獲得更少的參數(只有照片的名稱)。
我希望你能幫助我
非常感謝您
請看這個http://stackoverflow.com/a/12771707/1472432 –