-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Modernize scaffold generator #41210
Merged
Merged
Modernize scaffold generator #41210
Changes from all commits
Commits
Show all changes
99 commits
Select commit
Hold shift + click to select a range
c696fd7
Slim down scaffold css
dhh 22a8872
Use a box-style partial rather than a table
dhh cb1b5ce
Correct use of quotes
dhh a59d64c
Use modern array-of-strings declaration
dhh 3d495b0
Use double quotes for everything
dhh fb4b549
Fix syntax
dhh 1ac2745
Remove outdated viewport declaration
dhh e99ec71
Use double quotes everywhere
dhh 63b2ca2
Use symbols not strings for before_action scoping
dhh 74f3a28
Use human name to deal with double word records
dhh 52e5f15
Grab test fixes from #41219
dhh d0f2b3f
Fix tests
dhh 46a36d7
Use locar var not ivar
dhh 9482270
Fix capitalization change
dhh b9cca44
Update railties/lib/rails/generators/rails/app/templates/app/views/la…
dhh 91147ee
Update railties/test/generators/scaffold_controller_generator_test.rb
dhh 651914e
Update railties/test/generators/scaffold_controller_generator_test.rb
dhh 900cba0
Fix test
dhh 1361075
Update railties/test/generators/scaffold_generator_test.rb
dhh 91d74b6
Correct logic warning about initializers
gmcgibbon e979780
Rename master to main in all code references
rafaelfranca 1fe64ee
Use length == 0 instead of empty in Preloader
jhawthorn ecbb688
Add regression tests for preloader query count
jhawthorn b456bac
ActionCable guides suggest test adapter for test env [ci skip]
santib 0593d55
Changing 'rails new' --master to be --main
MikeRogers0 bef0f43
I think passing in the --master argument to run_generator is the way …
MikeRogers0 4adb2fb
Removing .count to figure out why its failing
MikeRogers0 c60040c
Raise unknown type error on the definition time
kamipo b63dd82
Refactor `attribute` not to reference `&block`
kamipo eb51999
Use major + minor AR versions in 'Directly inheriting' error message
radar ff0f158
Raise error when passing passing a class to :source_type
intrip 762df3f
Adding badges and logo to README and CONTRIBUTING page
guillaumebriday c164172
switch references to main branch in docs
hummusonrails 7c516bf
Updating references to /rails/blob/master & raiks/tree/master to poin…
MikeRogers0 f6f10d7
Don't return query cache enabled pools in the query cache executor
kamipo bd9aab9
Remove trailing commas in advanced route constraints example
14cb3a9
Search for yarn.cmd and yarn.ps1 in bin/yarn
jonathanhefner b4779d4
Run bin/yarn via Ruby
jonathanhefner 21c5eb8
Allow to opt-out of `strict_loading` mode on a per-record base.
ayrton 4447596
Fix granular connection swapping when there are multiple abstract cla…
eileencodes 89c1122
Avoid testing Thor internals
jonathanhefner 0ad4761
Fix the benchmark script to point to the main branch
rafaelfranca fd742e2
Resolve default annotation tags after config loads
jonathanhefner fbd602e
Upgrade all the gems to make sure we are testing with the latest vers…
rafaelfranca 7b8c237
Don't bother checking if strings respond to string methods
shioyama 07bedbc
Update name of input to fix typo
ttilberg a5a2a72
`connected_to` shouldn't be called on the abstract class that not est…
alpaca-tc fd71435
Add Webpacker to Guides list
ghiculescu 37c1e2b
Update documents.yaml
fxn e015754
Fix unintialized instance variable connection_class
eileencodes a40f271
Webpacker guide: remove Basecamp reference [docs]
ghiculescu c73f29f
fix broken link
ghiculescu ea527fb
Update webpacker.md
ghiculescu ccac38d
Added the unless-block for continuity
ijlee2 579dd34
Added :status for continuity
ijlee2 1cb335b
Removed line for continuity
ijlee2 8802a87
Added a new line after the include statement
ijlee2 b089b48
Connection specification now passes the "url" key to the adapter
malomalo 65393f8
Support hash config for `structure_dump_flags` and `structure_load_fl…
Aguardientico 776f988
Update test docs in "contributing to Rails" guide
ghiculescu 216c155
Fix current_page? with kwargs on ruby3
intrip 31a909c
`start_with?` allows multiple prefix values
kamipo d9886a5
Fix code block in Webpacker Guide [ci skip]
houhoulis 8c55224
Remove wrong usage for `arel_table` [ci skip]
kamipo c968bbf
Restore ActiveStorage::Blob#find_signed
composerinteralia a6e0605
Handle throwing in controller action in log subscriber
janko 6a5fd29
Improve Fixture support for Active Storage (#41065)
seanpdoyle 6216346
Improve ActionText::FixtureSet documentation (#41062)
seanpdoyle 752a169
Fix Flaky ActiveStorage test (#41225)
seanpdoyle 24c992a
Fix doc: stylesheet_include_tag -> stylesheet_link_tag
andrehjr fe5a34a
Remove reference to globalize gem
yboulkaid 1ab1669
Fix typo [ci skip]
orhantoy d728737
Add small improvements to the Webpacker guide
davidstosik 3207bb6
Fixing delegated types example.
andrewculver b5bb707
Allow jobs to rescue all exceptions
etiennebarrie ab87cf5
Guides: Missing erb tags for stylesheet_pack_tag [ci skip]
t27duck 94203cc
Guides: Remove unneeded statement about stylesheet_pack_tag [ci skip]
t27duck d3236f8
Update test names to match their behaviour
samjewell 92e5469
Remove SET NAMES, set collation using variable
robinroestenburg 6acd284
Update test helper to call parallelize according to fork support
bjfish 3c6eebc
Show a warning when running no migration using SCOPE
intrip fb560a2
Move ActiveStorage fixture hooks to on_load
seanpdoyle df247e6
Improve ActiveRecord strict_loading documentation
cveneziani da168a8
Remove legacy media=screen default from stylesheet_link_tag.
andrehjr 4aa259d
Do not eagerly load Request before initializers
rafaelfranca db71539
Change Request#media_type to return nil
rafaelfranca 8fafc97
`ActionDispatch::Request#content_type` now returned Content-Type head…
rafaelfranca d90c714
Disable rubocop suggestions
rafaelfranca acc08f1
Fix typo in the CHANGELOG
rafaelfranca e2b6679
Add config.action_view.stylesheet_media_default to baseline config
rafaelfranca af8c4ec
Rename the config to make clear it is a boolean
rafaelfranca 0bc559e
Add CHANGELOG entry for #41215
rafaelfranca 53fdc46
Fix CI failure due to `app.config.action_view.delete(:apply_apply_sty…
kamipo d6925af
Fix deprecation message s/Rails 6.1 will return/Rails 7.0 will return/
kamipo 7a19e97
Revert "Merge pull request #41192 from kamipo/dont_return_pools"
eileencodes 1ce7c6e
Revert "Merge pull request #41046 from eileencodes/dont-check-if-qc-i…
eileencodes 6376355
Ensure test rake commands run immediately
etiennebarrie f0bff35
Fix typo
st0012 6c51242
Merge branch 'main' into modernize-scaffold
dhh File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
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
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
12 changes: 8 additions & 4 deletions
12
railties/lib/rails/generators/erb/scaffold/templates/edit.html.erb.tt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
<h1>Editing <%= singular_table_name.titleize %></h1> | ||
<h1>Editing <%= human_name.downcase %></h1> | ||
|
||
<%%= render 'form', <%= singular_table_name %>: @<%= singular_table_name %> %> | ||
<%%= render "form", <%= singular_table_name %>: @<%= singular_table_name %> %> | ||
|
||
<%%= link_to 'Show', @<%= singular_table_name %> %> | | ||
<%%= link_to 'Back', <%= index_helper %>_path %> | ||
<br> | ||
|
||
<div> | ||
<%%= link_to "Show this <%= human_name.downcase %>", @<%= singular_table_name %> %> | | ||
<%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper %>_path %> | ||
</div> |
32 changes: 5 additions & 27 deletions
32
railties/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,9 @@ | ||
<p id="notice"><%%= notice %></p> | ||
|
||
<h1><%= plural_table_name.titleize %></h1> | ||
<h1><%= human_name %></h1> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<% attributes.reject(&:password_digest?).each do |attribute| -%> | ||
<th><%= attribute.human_name %></th> | ||
<% end -%> | ||
<th colspan="3"></th> | ||
</tr> | ||
</thead> | ||
<div id="<%= plural_table_name %>"> | ||
<%%= render @<%= plural_table_name %> %> | ||
</div> | ||
|
||
<tbody> | ||
<%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %> | ||
<tr> | ||
<% attributes.reject(&:password_digest?).each do |attribute| -%> | ||
<td><%%= <%= singular_table_name %>.<%= attribute.column_name %> %></td> | ||
<% end -%> | ||
<td><%%= link_to 'Show', <%= model_resource_name %> %></td> | ||
<td><%%= link_to 'Edit', edit_<%= singular_route_name %>_path(<%= singular_table_name %>) %></td> | ||
<td><%%= link_to 'Destroy', <%= model_resource_name %>, method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
</tr> | ||
<%% end %> | ||
</tbody> | ||
</table> | ||
|
||
<br> | ||
|
||
<%%= link_to 'New <%= singular_table_name.titleize %>', new_<%= singular_route_name %>_path %> | ||
<%%= link_to "New <%= human_name.downcase %>", new_<%= singular_route_name %>_path %> |
10 changes: 7 additions & 3 deletions
10
railties/lib/rails/generators/erb/scaffold/templates/new.html.erb.tt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
<h1>New <%= singular_table_name.titleize %></h1> | ||
<h1>New <%= human_name.downcase %></h1> | ||
|
||
<%%= render 'form', <%= singular_table_name %>: @<%= singular_table_name %> %> | ||
<%%= render "form", <%= singular_table_name %>: @<%= singular_table_name %> %> | ||
|
||
<%%= link_to 'Back', <%= index_helper %>_path %> | ||
<br> | ||
|
||
<div> | ||
<%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper %>_path %> | ||
</div> |
20 changes: 20 additions & 0 deletions
20
railties/lib/rails/generators/erb/scaffold/templates/partial.html.erb.tt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<div id="<%%= dom_id <%= singular_table_name %> %>" class="scaffold_record"> | ||
<% attributes.reject(&:password_digest?).each do |attribute| -%> | ||
<p> | ||
<strong><%= attribute.human_name %>:</strong> | ||
<% if attribute.attachment? -%> | ||
<%%= link_to <%= singular_table_name %>.<%= attribute.column_name %>.filename, <%= singular_table_name %>.<%= attribute.column_name %> if <%= singular_table_name %>.<%= attribute.column_name %>.attached? %> | ||
<% elsif attribute.attachments? -%> | ||
<%% <%= singular_table_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>| %> | ||
<div><%%= link_to <%= attribute.singular_name %>.filename, <%= attribute.singular_name %> %></div> | ||
<%% end %> | ||
<% else -%> | ||
<%%= <%= singular_table_name %>.<%= attribute.column_name %> %> | ||
<% end -%> | ||
</p> | ||
|
||
<% end -%> | ||
<p> | ||
<%%= link_to "Show this <%= human_name %>", <%= singular_table_name %> %> | ||
</p> | ||
</div> |
23 changes: 7 additions & 16 deletions
23
railties/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,10 @@ | ||
<p id="notice"><%%= notice %></p> | ||
|
||
<% attributes.reject(&:password_digest?).each do |attribute| -%> | ||
<p> | ||
<strong><%= attribute.human_name %>:</strong> | ||
<% if attribute.attachment? -%> | ||
<%%= link_to @<%= singular_table_name %>.<%= attribute.column_name %>.filename, @<%= singular_table_name %>.<%= attribute.column_name %> if @<%= singular_table_name %>.<%= attribute.column_name %>.attached? %> | ||
<% elsif attribute.attachments? -%> | ||
<%% @<%= singular_table_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>| %> | ||
<div><%%= link_to <%= attribute.singular_name %>.filename, <%= attribute.singular_name %> %></div> | ||
<%% end %> | ||
<% else -%> | ||
<%%= @<%= singular_table_name %>.<%= attribute.column_name %> %> | ||
<% end -%> | ||
</p> | ||
<%%= render @<%= singular_table_name %> %> | ||
|
||
<% end -%> | ||
<%%= link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>) %> | | ||
<%%= link_to 'Back', <%= index_helper %>_path %> | ||
<div> | ||
<%%= link_to "Edit this <%= human_name.downcase %>", edit_<%= singular_table_name %>_path(@<%= singular_table_name %>) %> | | ||
<%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper %>_path %> | ||
|
||
<%%= button_to "Destroy this <%= human_name.downcase %>", <%= singular_table_name %>_path(@<%= singular_table_name %>), method: :delete %> | ||
dhh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</div> |
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The association was used below to demonstrate usage of strict_loading on a Model. Is the removal intentional or removed by mistake while rebasing the PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mistake, adding back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Raised a PR for it: #41329. Please feel free to close it if you have added the change back 😊