0

テスト用のymlファイルでPaperclipフィールドを指定する最良の方法は何ですか? 考えられる解決策の 1 つは、 Fixtures with Paperclipで概説されていますが、それを機能させる方法がわかりません。

ここに私が持っているものがあります:

モデル.yml

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

乾杯、アンドレイ

4

1 に答える 1

0

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
于 2012-10-18T05:03:28.020 に答える