我正在尋找一種方法將照片上載到數據庫並在頁面上顯示照片。我正在嘗試載波。我認爲它正確地上傳了照片,但是當它顯示圖像時,它只會提供它的位置(url)。用Carrierwave不顯示圖像
這裏是上傳
class Image < ActiveRecord::Base
attr_accessible :image, :title
mount_uploader :image, ImageUploader
end
這裏被用來上傳文件
<%= form_for @image, :html => {:multipart => true} do |f| %>
<% if @image.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@image.errors.count, "error") %> prohibited this image from being saved:</h2>
<ul>
<% @image.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :image %><br />
<%= f.file_field :image %>
</div>
<div class="field">
<%= f.label :title %><br />
<%= f.text_field :title %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
這是顯示圖像
<p id="notice"><%= notice %></p>
<p>
<b>Image:</b>
<%= @image.image_url.to_s %>
</p>
<p>
<b>Title:</b>
<%= @image.title %>
</p>
<%= link_to 'Back', images_path %>
這是打印出來的表格:
圖片:/uploads/image/image/2/946612_524939910875157_1455921715_n.jpg
標題:海報
變化'<%= @ image.image_url.to_s%>''到<%= IMAGE_TAG @ image.image_url.to_s%>' – 2013-05-07 10:36:05