回形针能够成功上传图像(将其上传到服务器上的相应文件夹)。但是,当我尝试查看图像时,它会将其报告为丢失。回形针报告上传的图像丢失。我怎样才能找到它?
型号/ photo.rb:
class Photo < ActiveRecord::Base
attr_accessible :image
attr_accessor :image_file_name, :image_file_size, :image_updated_at
has_attached_file :image, styles: {small: "300x300>" },
url "/photos/:id/:style/:basename.:extension",
path: ":rails_root/public/photos/:id/:style/:basename.:extension"
validates_attachment_presence :image
validates_attachment_size :image, less_than: 5.megabytes
end
观看图像(照片/ show.html.erb):
<% if @photo.image? %>
<%= image_tag @photo.image.url(:small) %>
<% else %>
Missing image <%= @photo.id %>
<% end %>
这个输出 “缺少像” 用正确的带照片的身份证。
尽管如此,上传的照片存储在正确的路径,并可通过正确的URL访问,例如,
http://localhost:3000/photos/1/small/1351546785_accepted_48.png