1.在成功安装ImageMagick了后对图片处理是出现下面错误:
An error was received while processing: #<Paperclip::Errors::NotIdentifiedBy ImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
错误解决:在Rails项目的config/environments/development.rb文件加入:
Paperclip.options[:command_path] = '/opt/local/bin/' #Mac OS 下
然后重启服务器。
(ps: imageMagick和Paperclip的安装请转到 http://unremittingly.iteye.com/blog/2019512)
2.用Paperclip上传的图片如何删除。
image_news_deleted = ImageNews.find(params[:id])#根据id找到对应的image_news
image_news_deleted.image.destroy #删除image_news对应的存储在public文件夹下的image
ImageNews.delete(params[:id]) #删除存储的image_news
(
ps:ImageNews模型相关属性的创建请见我的
http://unremittingly.iteye.com/blog/2019512)