【发布时间】:2017-01-07 06:08:45
【问题描述】:
如果图像存储在 assets/images/Garden3.jpeg 中,如何使用回形针 gem 调出图像?我使用 rails 控制台自己添加了记录,以下是数据库中的值:
#<Product id: 1, product_code: "FB_60", product_description: "Fruits: Apple,Orange,Banana Flowers: Zebra, Chrysa...", price: #<BigDecimal:7f9ec73ec430,'0.6E2',9(18)>, product_image_file_name: "Garden3.jpeg", product_image_content_type: "jpeg", product_image_file_size: nil, product_image_updated_at: nil, category_id: 1>
我在目录asset/images/Garden3.jpeg 中有一张图片。产品模型将加载图像并显示图像、价格和详细信息。在我的产品模型中,我有:
class Product < ActiveRecord::Base
belongs_to :category
has_attached_file :product_image, styles: { small: "64x64", med: "100x100", large: "200x200" },
:url => "/system/products/product_images/000/000/:id/:style/:basename.:extension",
:path => ":rails_root/app/assets/images/:basename:extension"
end
我还允许在控制器中使用参数名称 :product_image。但是,当我运行该应用程序时,除了图像图标之外没有显示任何图像:
我可以知道我该如何处理这个问题吗?感谢并感谢我能得到一些解释以改进它。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 rubygems paperclip