我正在添加carrierwave_mongoid 来存储图像,我已经将图像保存到mongo 我的数据是这样的:
{ "contentType" : "image/jpeg", "length" : 512659, "chunkSize" : 4194304, "uploadDate" : ISODate("2013-01-26T00:00:00Z"), "md5" : "3d44aa8fcfba7cae34fe9a592407410b", "filename" : "uploads/deal/image/295/15a11db8e441c610330af53a77e2b136.jpg", "_id" : 5 }
我有一个故事模型:
class Deal
include Mongoid::Document
include Mongoid::Timestamps
field :image, :type => String
field :status, :type => Integer
mount_uploader :image, ImageUploader
end
我的 ImageUploader 代码在这里:
class ImageUploader < CarrierWave::Uploader::Base
...
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
现在我想显示来自 mongodb 的图像,并且在我的视图中
<%= image_tag(@deal.image.url) %>
最后图像未显示在视图中并出现以下错误:
ActionController::RoutingError (No route matches [GET] "/assets/uploads/deal/image/295/15a11db8e441c610330af53a77e2b136.jpg"):
我想知道如何通过carrierwave_mongoid 读取图像