garrytan/spawn ? reverse-engineered prompt

Reverse engineered prompt

Build me a small Ruby on Rails plugin called Spawn that lets me run long tasks in the background with a simple spawn do ... end block.

It should let a controller return right away while the work keeps going in either a forked process or a thread, with fork as the default. I want a way to wait for a group of spawned jobs to finish, and I want to be able to pass options like running the child at a lower priority and choosing thread mode when needed.

Please make it work cleanly with older Rails versions too, especially around ActiveRecord connections, since the spawned block needs its own database connection and there are known thread related issues to handle. If thread mode is used, check that the app is configured for concurrency and raise a clear error if not.

Also add simple environment based configuration so I can choose different spawn methods in development, test, and production. Keep it easy to drop into an old Rails app.

Are you gonna build this?

make sure you review the code using coderabbit

Try freeSponsored — opens CodeRabbit in a new tab