mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Default to yielding a form
variable.
More intention revealing and means `f` can go F itself 😋
This commit is contained in:
parent
8534d2e179
commit
8ff7ca5d11
2 changed files with 12 additions and 12 deletions
|
@ -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 %>
|
||||
|
|
|
@ -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|
|
||||
|
|
Loading…
Reference in a new issue