Skip to content

Commit 76b7eaf

Browse files
committed
Don't add solid_queue.connects_to configuration more than once
Or, in other words, make the install generator idempotent. Inspired by #349
1 parent 2e9eab1 commit 76b7eaf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/generators/solid_queue/install/install_generator.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ def copy_files
1111
chmod "bin/jobs", 0755 & ~File.umask, verbose: false
1212
end
1313

14-
def configure_active_job_adapter
15-
gsub_file Pathname(destination_root).join("config/environments/production.rb"),
16-
/(# )?config\.active_job\.queue_adapter\s+=.*/,
14+
def configure_adapter_and_database
15+
pathname = Pathname(destination_root).join("config/environments/production.rb")
16+
17+
gsub_file pathname, /\n\s*config\.solid_queue\.connects_to\s+=.*\n/, "\n", verbose: false
18+
gsub_file pathname, /(# )?config\.active_job\.queue_adapter\s+=.*\n/,
1719
"config.active_job.queue_adapter = :solid_queue\n" +
1820
" config.solid_queue.connects_to = { database: { writing: :queue } }\n"
1921
end

0 commit comments

Comments
 (0)