diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2017-03-20 19:57:56 +0100 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2017-03-20 19:57:56 +0100 |
commit | 8ff7ca5d112a5db5c1449f687e5bdc15e3670579 (patch) | |
tree | 45add63e78e2c132684f0e3ac9380ce632541aa9 | |
parent | 8534d2e17987b0d0da9302fd18ca3aa5745d3cf5 (diff) | |
download | rails-8ff7ca5d112a5db5c1449f687e5bdc15e3670579.tar.gz rails-8ff7ca5d112a5db5c1449f687e5bdc15e3670579.tar.bz2 rails-8ff7ca5d112a5db5c1449f687e5bdc15e3670579.zip |
Default to yielding a `form` variable.
More intention revealing and means `f` can go F itself 😋
-rw-r--r-- | railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb | 16 | ||||
-rw-r--r-- | railties/test/generators/scaffold_generator_test.rb | 8 |
2 files changed, 12 insertions, 12 deletions
diff --git a/railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb b/railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb index ac8a568071..73c00ad41a 100644 --- a/railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb +++ b/railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb @@ -1,4 +1,4 @@ -<%%= form_with(model: <%= singular_table_name %>, local: true) do |f| %> +<%%= form_with(model: <%= singular_table_name %>, local: true) do |form| %> <%% if <%= singular_table_name %>.errors.any? %> <div id="error_explanation"> <h2><%%= pluralize(<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2> @@ -14,21 +14,21 @@ <% attributes.each do |attribute| -%> <div class="field"> <% if attribute.password_digest? -%> - <%%= f.label :password %> - <%%= f.password_field :password %> + <%%= form.label :password %> + <%%= form.password_field :password %> </div> <div class="field"> - <%%= f.label :password_confirmation %> - <%%= f.password_field :password_confirmation %> + <%%= form.label :password_confirmation %> + <%%= form.password_field :password_confirmation %> <% else -%> - <%%= f.label :<%= attribute.column_name %> %> - <%%= f.<%= attribute.field_type %> :<%= attribute.column_name %> %> + <%%= form.label :<%= attribute.column_name %> %> + <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %> %> <% end -%> </div> <% end -%> <div class="actions"> - <%%= f.submit %> + <%%= form.submit %> </div> <%% end %> diff --git a/railties/test/generators/scaffold_generator_test.rb b/railties/test/generators/scaffold_generator_test.rb index b9c2e791da..0e0ef7d293 100644 --- a/railties/test/generators/scaffold_generator_test.rb +++ b/railties/test/generators/scaffold_generator_test.rb @@ -437,8 +437,8 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase end assert_file "app/views/accounts/_form.html.erb" do |content| - assert_match(/^\W{4}<%= f\.text_field :name %>/, content) - assert_match(/^\W{4}<%= f\.text_field :currency_id %>/, content) + assert_match(/^\W{4}<%= form\.text_field :name %>/, content) + assert_match(/^\W{4}<%= form\.text_field :currency_id %>/, content) end end @@ -461,8 +461,8 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase end assert_file "app/views/users/_form.html.erb" do |content| - assert_match(/<%= f\.password_field :password %>/, content) - assert_match(/<%= f\.password_field :password_confirmation %>/, content) + assert_match(/<%= form\.password_field :password %>/, content) + assert_match(/<%= form\.password_field :password_confirmation %>/, content) end assert_file "app/views/users/index.html.erb" do |content| |