class Rack::SSL::Railtie < ::Rails::Railtie
  initializer "middleware" do
    if config.force_ssl
      config.middleware.use Rack::SSL
    end
  end
end

class Rack::SSL::Railtie < ::Rails::Railtie
  initializer "middleware" do
    if config.respond_to?(:force_ssl) && config.force_ssl
      Rails.application.config.middleware.insert_before ActionDispatch::Static, Rack::SSL
    end
  end
end

Update Railtie for multiple cases
Update Railtie for multiple cases