Skip to content

Commit f686b75

Browse files
skipkayhilJonRowe
andauthored
Use implication for skip_active_record/skip_solid (rails#52802)
* Generator options should default to nil for unset The generator options are effectively tri-state, with true/false meaning set by the user and nil being unset. However, some of these options were defaulting to false, meaning they were being treated as set to false by the user. This commit fixes this issue by setting the values to nil by default instead of false so that they are properly "unset" by user. * Use implication for skip_active_record/skip_solid When skip_solid was added, it used the "old style" option implication where skip_*? methods delegate to all the options that should be implied. This has a few downsides such as making it unclear to users when conflicting options may be specified (for example, skip_active_record and no_skip_solid). This commit changes the skip_solid option to use the new style of implication so that error messages are better and the predicate method is simpler. Co-authored-by: Jon Rowe <[email protected]> --------- Co-authored-by: Jon Rowe <[email protected]>
1 parent 17ba9d2 commit f686b75

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

railties/lib/rails/generators/app_base.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,16 @@ def self.add_shared_options_for(name)
111111
class_option :skip_ci, type: :boolean, default: nil,
112112
desc: "Skip GitHub CI files"
113113

114-
class_option :skip_kamal, type: :boolean, default: false,
114+
class_option :skip_kamal, type: :boolean, default: nil,
115115
desc: "Skip Kamal setup"
116116

117-
class_option :skip_solid, type: :boolean, default: false,
117+
class_option :skip_solid, type: :boolean, default: nil,
118118
desc: "Skip Solid Cache & Queue setup"
119119

120120
class_option :dev, type: :boolean, default: nil,
121121
desc: "Set up the #{name} with Gemfile pointing to your Rails checkout"
122122

123-
class_option :devcontainer, type: :boolean, default: false,
123+
class_option :devcontainer, type: :boolean, default: nil,
124124
desc: "Generate devcontainer files"
125125

126126
class_option :edge, type: :boolean, default: nil,
@@ -206,7 +206,7 @@ def deduce_implied_options(options, option_reasons, meta_options)
206206

207207
OPTION_IMPLICATIONS = { # :nodoc:
208208
skip_active_job: [:skip_action_mailer, :skip_active_storage],
209-
skip_active_record: [:skip_active_storage],
209+
skip_active_record: [:skip_active_storage, :skip_solid],
210210
skip_active_storage: [:skip_action_mailbox, :skip_action_text],
211211
skip_javascript: [:skip_hotwire],
212212
}
@@ -432,7 +432,7 @@ def skip_kamal?
432432
end
433433

434434
def skip_solid?
435-
options[:skip_active_record] || options[:skip_solid]
435+
options[:skip_solid]
436436
end
437437

438438
class GemfileEntry < Struct.new(:name, :version, :comment, :options, :commented_out)

railties/test/generators/shared_generator_tests.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ def test_generator_if_skip_active_record_is_given
279279
assert_gitattributes_does_not_have_schema_file
280280

281281
assert_file "Gemfile" do |contents|
282+
assert_no_match(/solid_cache/, contents)
282283
assert_no_match(/sqlite/, contents)
283284
end
284285
end

0 commit comments

Comments
 (0)