diff --git a/lib/install/web.rb b/lib/install/web.rb index b071c4d7..7fbe181f 100644 --- a/lib/install/web.rb +++ b/lib/install/web.rb @@ -10,6 +10,20 @@ def node_version_unsupported? node_version < "20.0.0" end +def rails_version + version = `rails --version`[/\d+\.\d+\.\d+/] + + return if version.blank? + + Gem::Version.new(version) +end + +def rails_version_unsupported? + minimum_rails_version = Gem::Version.new("7.2.0") + + rails_version < minimum_rails_version +end + def apply_template! if node_not_installed? || node_version_unsupported? message = <<~ERROR @@ -22,6 +36,22 @@ def apply_template! fail Rails::Generators::Error, message end + + if rails_version_unsupported? + message = <<~ERROR + + + === Rails version unsupported for creating new apps === + + Suspenders requires Rails >= 7.2.0 when creating a **new** app. + + Suspenders can be added to an **existing** app meeting "~> 7.0.0". + + ERROR + + fail Rails::Generators::Error, message + end + if options[:database] == "postgresql" && options[:skip_test] && options[:skip_rubocop] after_bundle do gem_group :development, :test do