Skip to content

Commit

Permalink
seeds.rb整備
Browse files Browse the repository at this point in the history
  • Loading branch information
KOH6 committed Sep 6, 2023
1 parent a786922 commit ea64b88
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
Binary file removed app/assets/images/450x300.jpg
Binary file not shown.
12 changes: 1 addition & 11 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@

# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
require 'aws-sdk-s3'

# 本番環境の場合S3にテストデータ用画像が保存されているため、Herokuのローカルへ再保存する。
image_path = 'app/assets/images/dummy.jpg'

# if Rails.env.production?
# s3 = Aws::S3::Resource.new(region: ENV['AWS_REGION'])
# obj = s3.bucket(ENV['AWS_BUCKET']).object('images/dummy.jpg')
# obj.get(response_target: image_path)
# end

10.times do |n|
count = n + 1
Expand All @@ -22,5 +12,5 @@
stock: 5 * count,
description: "descriptionTest#{count}ダミー説明ダミー説明ダミー説明ダミー説明ダミー説明ダミー説明ダミー説明ダミー説明ダミー説明ダミー説明"
)
product.image.attach(io: File.open(Rails.root.join(image_path)), filename: 'dummy.jpg')
product.image.attach(io: File.open(Rails.root.join('app/assets/images/dummy.jpg')), filename: 'dummy.jpg')
end

0 comments on commit ea64b88

Please sign in to comment.