-
-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable scaffold generator to create phlex classes not erb files #234
Open
rubyforbusiness
wants to merge
15
commits into
phlex-ruby:v1
Choose a base branch
from
rubyforbusiness:scaffold-generator-phlex-not-erb-v1
base: v1
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Enable scaffold generator to create phlex classes not erb files #234
rubyforbusiness
wants to merge
15
commits into
phlex-ruby:v1
from
rubyforbusiness:scaffold-generator-phlex-not-erb-v1
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Goodcop config was using an old URL
The issues fixed in the branch have been resolved, merged, released.
…B templates * use phlex 1.11.0 rather than deleted branch * update ApplicationComponent template to include helpers and methods needed for scaffold generation * add generator for phlex views and controllers via scaffold, by installing these files: ``` (in local app) lib/templates/rails/scaffold_controller/controller.rb.tt (ref in gem) lib/generators/rails/phlex_scaffold/phlex_scaffold_generator.rb ``` Usage: Simple example: ``` bin/rails g scaffold author name:string auth_token:token --template-engine=phlex_scaffold ``` Complex example, testing all field types, attachments and an association (the model above) * NB: uncomment 'bcrypt' and 'image_processing' in Rails 7 Gemfile, bundle and restart server ``` bin/rails active_storage:install bin/rails g scaffold article title:string body:text finalised:boolean viewed:date commission_rate:float password:digest avatar:attachment images:attachments author:references --template-engine=phlex_scaffold ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
NB: the target of this change is
phlex-rails:v1
- because there have been some breaking changes in v2 and because many people will not be able to move to Ruby 3.3 easily which v2 demands.See the commit message 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?