So you want to add a partial to the rails scaffold generator? Well reading the guide on generators wont tell you exactly what you need so I will.

Rails 7 removed table generation and I want it back; but I always preferred my table in a separate partial that I can use when and where I want. Let's make that happen.

Unfortunately the view templates generated by scaffold are hardcoded in the ScaffoldGenerator. We will create a config/initializers/gen_ext.rb and add our _table name to the hard coded list like so.

require "rails/generators/erb/scaffold/scaffold_generator"
Erb::Generators::ScaffoldGenerator.send(:undef_method, :available_views)
Erb::Generators::ScaffoldGenerator.send(:define_method, :available_views, ->(){
    %w(index edit show new _form _table)
})
Erb::Generators::ScaffoldGenerator.send(:private, :available_views)