From b24c96010da4399e79a9b3aa2f4d8f4d48c60a7d Mon Sep 17 00:00:00 2001 From: Lennart Melzer Date: Fri, 18 Sep 2020 09:06:37 +0200 Subject: [PATCH] add image in podcast seeds in suggested way (#10371) as described in [the carrierwave wiki](https://github.com/carrierwaveuploader/carrierwave/wiki/How-to:-%22Upload%22-from-a-local-file/7041728c73d24abdfbd4972b9c51aac6b99dcde4) otherwise seeding fails on Podcast validations: ``` ActiveRecord::RecordInvalid: Validation failed: Image Image has an unsupported type, Image can't be blank /opt/apps/bundle/gems/activerecord-6.0.3.3/lib/active_record/validations.rb:80:in `raise_validation_error' /opt/apps/bundle/gems/activerecord-6.0.3.3/lib/active_record/validations.rb:53:in `save!' ... /opt/apps/forem/db/seeds.rb:267:in `block (2 levels) in
' /opt/apps/forem/db/seeds.rb:266:in `each' /opt/apps/forem/db/seeds.rb:266:in `block in
' /opt/apps/forem/db/seeds.rb:19:in `create_if_none' /opt/apps/forem/db/seeds.rb:206:in `
' ``` --- db/seeds.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 26e5da2db..d4a9345c1 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -218,7 +218,7 @@ seeder.create_if_none(Podcast) do main_color_hex: "2faa4a", overcast_url: "https://overcast.fm/itunes919219256/codenewbie", android_url: "https://subscribeonandroid.com/feeds.podtrac.com/q8s8ba9YtM6r", - image: Rack::Test::UploadedFile.new(image_file, "image/jpeg"), + image: Pathname.new(image_file).open, published: true }, { @@ -231,7 +231,7 @@ seeder.create_if_none(Podcast) do main_color_hex: "111111", overcast_url: "https://overcast.fm/itunes769189585/coding-blocks", android_url: "http://subscribeonandroid.com/feeds.podtrac.com/c8yBGHRafqhz", - image: Rack::Test::UploadedFile.new(image_file, "image/jpeg"), + image: Pathname.new(image_file).open, published: true }, { @@ -244,7 +244,7 @@ seeder.create_if_none(Podcast) do main_color_hex: "181a1c", overcast_url: "https://overcast.fm/itunes979020229/talk-python-to-me", android_url: "https://subscribeonandroid.com/talkpython.fm/episodes/rss", - image: Rack::Test::UploadedFile.new(image_file, "image/jpeg"), + image: Pathname.new(image_file).open, published: true }, { @@ -258,7 +258,7 @@ seeder.create_if_none(Podcast) do main_color_hex: "343d46", overcast_url: "https://overcast.fm/itunes1006105326/developer-on-fire", android_url: "http://subscribeonandroid.com/developeronfire.com/rss.xml", - image: Rack::Test::UploadedFile.new(image_file, "image/jpeg"), + image: Pathname.new(image_file).open, published: true }, ]