Skip to content
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

Warn the user if we can't find target hooks for super scaffolding #995

Merged
merged 5 commits into from
Dec 20, 2024

Conversation

jagthedrummer
Copy link
Contributor

@jagthedrummer jagthedrummer commented Dec 20, 2024

The Scenario

Imagine you Super Scaffold a Project resource:

rails generate super_scaffold Project Team name:text_field

And then you open the Project model, and remove all of the target comments:

class Project < ApplicationRecord
  belongs_to :team

  validates :name, presence: true
end

And then you want to Super Scaffold a file_field onto Project.

rails generate super_scaffold:field Project documents:file_field{multiple}

Previously

Previously we would act like everything had gone according to plan, but in reality we wouldn't have updated the Project model with some important changes.

rails generate super_scaffold:field Project documents:file_field{multiple}
Adding new fields to Project with 'bin/rails generate migration add_documents_to_projects documents:attachments'

Updating './app/views/account/projects/_form.html.erb'.
Updating './app/views/account/projects/show.html.erb'.
Updating './app/views/account/projects/_index.html.erb'.
Replacing in './app/views/account/projects/_index.html.erb'.
Updating './app/views/account/projects/_project.html.erb'.
Updating './config/locales/en/projects.en.yml'.
Updating './config/locales/en/projects.en.yml'.
Updating './app/controllers/account/projects_controller.rb'.
Updating './app/controllers/account/projects_controller.rb'.
Updating './app/controllers/api/v1/projects_controller.rb'.
Updating './app/controllers/api/v1/projects_controller.rb'.
Updating './test/controllers/api/v1/projects_controller_test.rb'.
Updating './app/views/api/v1/projects/_project.json.jbuilder'.
Updating './test/controllers/api/v1/projects_controller_test.rb'.
Updating './app/models/project.rb'.
Updating './app/models/project.rb'.
Updating './app/models/project.rb'.
Updating './app/models/project.rb'.

You, as the developer, would think that everything worked, but then when you went to use the new attribute things wouldn't work quite right.

Now

Now we'll warn you that things did not go according to plan.

rails generate super_scaffold:field Project documents:file_field{multiple}
Adding new fields to Project with 'bin/rails generate migration add_documents_to_projects documents:attachments'

Updating './app/views/account/projects/_form.html.erb'.
Updating './app/views/account/projects/show.html.erb'.
Updating './app/views/account/projects/_index.html.erb'.
Replacing in './app/views/account/projects/_index.html.erb'.
Updating './app/views/account/projects/_project.html.erb'.
Updating './config/locales/en/projects.en.yml'.
Updating './config/locales/en/projects.en.yml'.
Updating './app/controllers/api/v1/projects_controller.rb'.
Updating './app/controllers/api/v1/projects_controller.rb'.
Updating './test/controllers/api/v1/projects_controller_test.rb'.
Updating './app/views/api/v1/projects/_project.json.jbuilder'.
Updating './test/controllers/api/v1/projects_controller_test.rb'.

-------------------------------
Heads up! We weren't able to find a super scaffolding hook where we expected it to be.
In ./app/models/project.rb
We expected to find a line like this:
# 🚅 add has_many associations above.

See https://bullettrain.co/docs/super-scaffolding/targets for more details.
-------------------------------


-------------------------------
Heads up! We weren't able to find a super scaffolding hook where we expected it to be.
In ./app/models/project.rb
We expected to find a line like this:
# 🚅 add attribute accessors above.

See https://bullettrain.co/docs/super-scaffolding/targets for more details.
-------------------------------


-------------------------------
Heads up! We weren't able to find a super scaffolding hook where we expected it to be.
In ./app/models/project.rb
We expected to find a line like this:
# 🚅 add methods above.

See https://bullettrain.co/docs/super-scaffolding/targets for more details.
-------------------------------


-------------------------------
Heads up! We weren't able to find a super scaffolding hook where we expected it to be.
In ./app/models/project.rb
We expected to find a line like this:
# 🚅 add callbacks above.

See https://bullettrain.co/docs/super-scaffolding/targets for more details.
-------------------------------

Fixes bullet-train-co/bullet_train#1753

@jagthedrummer jagthedrummer merged commit 613f21a into main Dec 20, 2024
32 checks passed
@jagthedrummer jagthedrummer deleted the jeremy/missing-scaffold-targets branch December 20, 2024 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Super scaffolding a field fails silently if target comments have been removed from the model
1 participant