【发布时间】:2016-06-08 19:33:11
【问题描述】:
我正在使用回形针将图像上传到 cloud9 虚拟环境 (ubuntu) 上的 rails 应用程序。有一个电影模型,每个电影对象都有一个与之关联的图像。
class Movie < ActiveRecord::Base
belongs_to :user
belongs_to :category
has_attached_file :movie_img, styles: { medium: "250x350>", thumb: "325x475>" }, default_url: "/images/style/missing.png"
validates_attachment_content_type :movie_img, content_type: '/\Aimage\/.*\Z/'
end
视图是这样的
<% @movies.each do |movie| %>
<%= image_tag movie.movie_img.url(:movie_index), class: "movie" %>
<% end %>
但是图片没有显示在网站上。
生成的html中图片的路径是这样的
系统/电影/movie_imgs/000/000/010/movie_index/fileName.jpg?1465401579 正如我从 Cloud9 的文件资源管理器中看到的那样,图像存在于实际目录中。
当我打开这个图片地址时,它显示以下错误。
没有路线匹配 [GET] "/system/movies/movie_imgs/000/000/011/movie_index/fileName.png"
同样在 config/environments/development.rb 我写了下面这行代码
Paperclip.options[:command_path] = "/usr/bin/"
因为当我在终端中输入 which convert 时,会出现以下内容。
/usr/bin/转换
我哪里错了?如何让图片出现在服务器中?
编辑 我还生成了必要的迁移,我的电影表看起来像这样。
create_table "movies", force: :cascade do |t|
t.string "title"
t.text "description"
t.string "director"
t.date "release_date"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "user_id"
t.integer "category_id"
t.string "movie_img_file_name"
t.string "movie_img_content_type"
t.integer "movie_img_file_size"
t.datetime "movie_img_updated_at"
结束
没有显示静止图像。
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-4 paperclip