【发布时间】:2013-10-13 09:24:01
【问题描述】:
大家好,我正在使用来自 https://github.com/thoughtbot/paperclip 的回形针宝石和来自 http://railscasts.com/episodes/134-paperclip 的导轨。
我在使用后无法显示我的图像:
<%= image_tag @post.photo.url %>
在我的帖子显示页面“show.html.erb”上。显示断开的链接图像而不是图像本身。
它在图像的 HTML 中有以下内容:
有没有人有任何提示来解决这个问题。提前致谢。
///////////////// 型号
class Post < ActiveRecord::Base
has_many :comments, as: :commentable, dependent: :destroy
validates :name, presence: true,
length: { minimum: 5}
has_attached_file :photo
end
/////////// 架构
create_table "posts", force: true do |t|
t.string "name"
t.date "date"
t.time "time"
t.text "description"
t.text "dresscode"
t.decimal "price"
t.datetime "created_at"
t.datetime "updated_at"
t.string "image"
t.string "photo_file_name"
t.string "photo_content_type"
t.integer "photo_file_size"
t.datetime "photo_updated_at"
end
【问题讨论】:
-
您可以在模型中指定图片路径和url。在 github 自述文件中查看。
-
很难在没有实际操作的情况下调试它。你有机会向我们展示比一行更多的代码吗?喜欢该表的模型和数据库架构吗?
-
对不起,我已经更新了这个问题。
-
您确定,您在表格中有图片网址,请检查
photo_file_name中的Database。 -
是的,我的架构文件中有 photo_file_name 字段
标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.2 rubygems