回形针图像未显示在rails app中 [英] Paperclip images not Displaying in rails app

查看:118
本文介绍了回形针图像未显示在rails app中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用回形针将图像上传到网站,但是当我这样做时,它会显示带有问号的图像占位符,而不是图像本身。我究竟做错了什么?
在模型中:

I'm using paperclip to upload images to the site but when I do, it shows the image placeholder with a question mark, not the image itself. What Am I doing wrong? In the model:

     attr_accessor :photo_file_name
     attr_accessor :photo_content_type
    attr_accessor :photo_file_size
    attr_accessor :photo_updated_at
    attr_accessible :photo


#paperclip-------------------------------
 has_attached_file :photo,
                 :url => "/:attachment/:id/:style/:basename.:extension",
                 :path => ":rails_root/public/:attachment/:id/:style/:basename.:extension"

在视图中:

<p id="notice"><%= notice %></p>
<div id="container">
<div id="content">
<%= image_tag @post.photo.url %>
<p>
  <b>Title:</b>
   <%= @post.title %>

以及我的表格:

<div class="field">
<%= post_form.file_field :photo %>
</div>


推荐答案

您是否检查过是否存储了图像文件:rails_root / public /:attachment /:id /:style / yet?

Did you check whether the image file is stored :rails_root/public/:attachment/:id/:style/ yet?

右键单击图像占位符以检查图像的网址,是不是?

Right click to the image place holder to check the url of the image, is it right?

这篇关于回形针图像未显示在rails app中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆