Skip to content

Commit 918c71f

Browse files
committed
Don’t create storage/ directory if not needed
The storage/ directory is used for sqlite or Active Storage. If using a different database and the --skip-active-storage option, this directory is not needed.
1 parent 72fccfb commit 918c71f

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

railties/lib/rails/generators/app_base.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,10 @@ def skip_active_storage? # :doc:
366366
options[:skip_active_storage]
367367
end
368368

369+
def skip_storage? # :doc:
370+
skip_active_storage? && !sqlite3?
371+
end
372+
369373
def skip_action_cable? # :doc:
370374
options[:skip_action_cable]
371375
end
@@ -784,7 +788,7 @@ def edge_branch
784788
def dockerfile_chown_directories
785789
directories = %w(log tmp)
786790

787-
directories << "storage" unless skip_active_storage? && !sqlite3?
791+
directories << "storage" unless skip_storage?
788792
directories << "db" unless skip_active_record?
789793

790794
directories.sort

railties/lib/rails/generators/rails/app/app_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ def create_system_test_files
455455
end
456456

457457
def create_storage_files
458-
build(:storage)
458+
build(:storage) unless skip_storage?
459459
end
460460

461461
def create_devcontainer_files

railties/test/generators/shared_generator_tests.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,13 @@ def test_generator_does_not_generate_active_storage_contents_if_skip_active_reco
312312
assert_no_file "#{application_path}/config/storage.yml"
313313
end
314314

315+
def test_generator_does_not_create_storage_dir_if_skip_active_storage_is_given_and_not_using_sqlite
316+
run_generator [destination_root, "--skip-active-storage", "--database=postgresql"]
317+
318+
assert_no_directory "#{application_path}/storage"
319+
assert_no_directory "#{application_path}/tmp/storage"
320+
end
321+
315322
def test_generator_if_skip_action_mailer_is_given
316323
run_generator [destination_root, "--skip-action-mailer"]
317324
assert_file "#{application_path}/config/application.rb", /#\s+require\s+["']action_mailer\/railtie["']/

0 commit comments

Comments
 (0)