-
Notifications
You must be signed in to change notification settings - Fork 22.2k
Closed
Labels
Description
Steps to reproduce
- Install ActiveStorage
- Create a
Postmodel withrails g model Post title:string& migrate - Add
has_one_attached :imageto thePostmodel - Add this code to db/seeds.rb:
post = Post.create(title: 'Test post')
post.image.attach(io: File.open("#{Rails.root}/test.png"), filename: "test.png")- Add a sample image with the file name
test.pngat the Rails root directory - Run
rails db:drop db:create db:migrate db:seed
Expected behavior
rails db:seed should run & exit successfully.
Actual behavior
rails db:seed will successfully seed the database but it will not exit the process.
System configuration
Rails version: 5.2.0
Ruby version: ruby 2.5.1p57
Attempts to fix
I tried referencing the file by a variable image = File.open("#{Rails.root}/test.png") & then attaching it to the post like this post.image.attach(io: image, filename: "test.png") & finally closing the file with image.close. It still caused the process to hang.
Workaround
Adding config.active_job.queue_adapter = :inline to config/environments/development.rb will fix the issue for some reason, I'm not quite sure why. That's why I'm guessing this issue has something to do with the inner workings of ActiveJob.
Reactions are currently unavailable