phlex-ruby / phlex-rails

An object-oriented alternative to ActionView for Ruby on Rails.
https://www.phlex.fun
MIT License
232 stars 40 forks source link

Enable scaffold generator to create phlex classes not erb files (phlex v2) #237

Closed rubyforbusiness closed 4 days ago

rubyforbusiness commented 1 month ago

This change enables the standard rails scaffold generator to create Phlex views instead of .erb templates.

It also wires up the generated controllers to these views. The actual look of the views is almost identical to the erb ones which means the generated standard tests all work fine.

The purpose is to showcase how Phlex can be used to create a (basic but well understood) object-oriented UI in Rails.

See the commit messages for how to try this out manually.

I've been through the rails generator code and tried all the cases I can find including attachments, password digests and references.

Unfortnately I couldn't find an easy way to test this automatically without interfering with the existing test/dummy/app installation. There are issues with rails locking the application layout file, and with wanting to run the generated tests from within the test that generates them!

I'd be happy to add tests in if someone can suggest a good way to do it. Perhaps creating a dummy2 app? Or perhaps putting all this generation code in a new repo?

NB: I've also fixed the existing tests to use the phlex v2 naming conventions (see 594fdbc5b4f799990c3f3237921aae9589490e8c)

joeldrapper commented 4 days ago

@rubyforbusiness I’m really sorry, but there’s too much to review and merge in one go here.