I thought I would load my standard “Watched Videos DB” into a new 7.0 app so I went through the creation of the app and used the usual scaffold and migrate to create the DB and then copied my existing stuff into the DB - but viewing the videos is showing a long list now instead of the table I was expecting - is there a built-in way to show the table now?
Not in the standard scaffolding, no. The new layout is trying to lean hard into the new Turbo tooling, and uses Turbo Frames to manage the layout of the various partials. Since you can’t put anything inside a TBODY that isn’t a TR, and a turbo frame is a custom element that isn’t a TR, this scheme would not work. Instead of figuring out a solution to that problem, they punted and used a nasty stack of DIVs in the index view.
Not in the standard scaffolding, no. The new layout is trying to lean
hard into the new Turbo tooling, and uses Turbo Frames to manage the
layout of the various partials. Since you can’t put anything inside
a TBODY that isn’t a TR, and a turbo frame is a custom element that
isn’t a TR, this scheme would not work. Instead of figuring out a
solution to that problem, they punted and used a nasty stack of DIVs
in the index view.
Damn - thanks for the clarification! So is there an idiot-proof way of
getting the table going again? - or at least something that doesn’t
require being a full-time Rails guru?
You can certainly make your own table, you just won’t get the benefit of the scaffold to generate it unless you hack the templates. That is certainly not impossible, and you can do this within your application, and thereafter, any further invocations of the rails generate scaffold ... command will use your templates instead of the ones provided by the gems.
This will let you fiddle with the templates until they do what you want them to. You can run the rails g scaffold TestModel command, check your work, then run the rails d scaffold TestModel command to delete everything before you make a change, then fiddle with your template again, and test again.
If you go back in time on that folder in Github, you should be able to see what that template used to look like before the table was removed, and copy and paste the relevant bits back into the index.html.erb.tt template.
If you really get it going the way you like it, you can extract those changes into a Gem, and then you can share it with the world (or at least use it to quickly get your other new apps to work in a more sane manner).
The new scaffold could also be a lean-in towards css-grid or css-flow. I haven’t looked closely, the nest of divs might be close to what’s needed for a simple css grid.
Just add a table to the index view and iterate through the model and generate TR’s. Don’t call the == render model
I even tried to have the partial return a TR, but that seem like a waste of calls
Not sure what people do if they have thousand of records with the new scheme. Tables are out, but for certain types of applications the new scheme just does not fit
A fun starting point to get back into Rails can be through “The Brick” gem. Like doing a scaffold, it creates models, controllers, and views for you – but it’s all in-memory and on-the-fly. It does this based on your existing database structure, turning foreign keys into belongs_to and has_many. It also turns database schema containers into namespaced modules, so does just fine interacting with complex databases. A sample walkthrough video on the Github repo shows more details:
if you will allow me a shameless plug, my gem Hot Glue I think does exactly what you need. The “tables” are implemented as a flexbox layout. It gives you the best of both worlds— auto generate scaffold within the Turbo paradigm, and it works in a clean, consistent way to help you build a modern interface with Rails (edit and create are all “in place” by default). Would appreciate any feedback to know if it suites your needs!