我正在使用Carrierwave,以便用戶可以上傳圖像。我正在創建一個博客網站。我沒有錯誤,但圖像沒有出現。我希望圖像顯示在發佈視圖中。這裏是我的代碼:Ruby-On-Rails如何顯示用戶上傳的圖像
Post.rb
mount_uploader :image, ImageUploader
帖子_form.html.erb
<div>
<%= form_for @post do |f|%>
<%= f.label :image %>
<%= f.file_field :image %>
</div>
image_uploader.rb
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def extension_white_list
%w(jpg jpeg gif png)
end
帖子show.html.erb
<strong>Image:</strong>
<%= image_tag @post.image_url%>
</p>
當我運行我的應用程序並查看帖子時,它只是說Image:下面沒有圖像。
UPDATE:
我安裝的ImageMagick/GraphicsMagick工具,當我去保存它張貼說:
1 error prohibited this post from being saved:
Image Failed to manipulate with MiniMagick, maybe it is not an image? `Original Error: ImageMagick/GraphicsMagick is not installed`
,並在其下面顯示的圖像,但它不會保存職位。
try @ post.image_url.to_s –
@TonyVincent不幸的是,沒有喜悅! – Jill