繁体   English   中英

yml固定装置回形针

[英]yml fixtures paperclip

在yml文件中为测试指定Paperclip字段的最佳方法是什么? 带有回形针的灯具中概述了一种可能的解决方案但是我不确定如何使它起作用。

这是我所拥有的:

模型

one:
  id: 2
  image: image.jpg

two:
  id: 2
  image: image.jpg

模型

class Doodle < ActiveRecord::Base

  attr_accessible :image
  has_attached_file :image,
                :styles => {:thumb => "100x100>"},
                :storage => :s3,
                :s3_credentials => S3_CREDENTIALS

干杯,安德烈

将Yaml文件放在config目录中,并在模型中使用它,如下所示:

class Doodle < ActiveRecord::Base

  s3_config_file = File.expand_path(File.join(File.dirname(__FILE__), 
                                          *%w[.. .. config cloud.yml]))

  attr_accessible :image
  has_attached_file :image,
            :styles => {:thumb => "100x100>"},
            :storage => :s3,
            :s3_credentials => s3_config_file

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM