For file uploads in Ruby, the “CarrierWave” gem seems to be convenient.
Since it supports Rack, it works with Rack-based Ruby applications like Rails and Sinatra, and supports many ORMs including ActiveRecord, DataMapper, and Mongoid.
・jnicklas/carrierwave · GitHub
・ASCIIcasts - “Episode 253 - CarrierWaveでファイルのアップロード”
・Railsでcarrierwaveを使って画像ファイルのアップロード
.gitignore
# CarrierWave
/public/uploads
When creating test data, you can assign an image to a model in rails c and save it.
photo = Photo.new
photo.image = File.open('app/assets/images/dummy.jpg')
include ActionDispatch::TestProcess
FactoryGirl.define do
factory :photo do
ignore do
image_file "test1.jpg"
end
name "TestPhoto"
image { fixture_file_upload(Rails.root.join('spec', 'support', 'test_images', "#{image_file}"), 'image/jpg') }
end
end
・Action*3 - rspecでCarrierWaveのアップロードファイルをclean
・How to: Cleanup after your Rspec tests · jnicklas/carrierwave Wiki
That’s all from the Gemba.