LoginSignup
16
16

More than 5 years have passed since last update.

FactoryGirlでpaperclip用のダミー画像を登録する方法

Last updated at Posted at 2012-11-02

paparclipを利用してattachementとして定義しているカラムにfactory_girlでフィクスチャデータを定義する際にダミーの画像を指定する方法。

適当な画像を用意してFile.openする

spec/factories/example.rb
FactoryGirl.define do
  factory :sample_example, :class => Example do
    id 1
    image { File.open("spec/file/dummy.jpg") }
  end
end
16
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
16