未验证 提交 b1f140ef 编写于 作者: K Kasper Timm Hansen 提交者: GitHub

Merge pull request #31229 from y-yagi/remove_field_ids_from_scaffold_form

Remove field ids from scaffold form
......@@ -15,15 +15,15 @@
<div class="field">
<% if attribute.password_digest? -%>
<%%= form.label :password %>
<%%= form.password_field :password, id: :<%= field_id(:password) %> %>
<%%= form.password_field :password %>
</div>
<div class="field">
<%%= form.label :password_confirmation %>
<%%= form.password_field :password_confirmation, id: :<%= field_id(:password_confirmation) %> %>
<%%= form.password_field :password_confirmation %>
<% else -%>
<%%= form.label :<%= attribute.column_name %> %>
<%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, id: :<%= field_id(attribute.column_name) %> %>
<%%= form.<%= attribute.field_type %> :<%= attribute.column_name %> %>
<% end -%>
</div>
......
......@@ -114,10 +114,6 @@ def new_helper # :doc:
"new_#{singular_route_name}_url"
end
def field_id(attribute_name)
[singular_table_name, attribute_name].join("_")
end
def singular_table_name # :doc:
@singular_table_name ||= (pluralize_table_names? ? table_name.singularize : table_name)
end
......
......@@ -471,8 +471,8 @@ def test_scaffold_generator_belongs_to
end
assert_file "app/views/accounts/_form.html.erb" do |content|
assert_match(/^\W{4}<%= form\.text_field :name, id: :account_name %>/, content)
assert_match(/^\W{4}<%= form\.text_field :currency_id, id: :account_currency_id %>/, content)
assert_match(/^\W{4}<%= form\.text_field :name %>/, content)
assert_match(/^\W{4}<%= form\.text_field :currency_id %>/, content)
end
end
......@@ -495,8 +495,8 @@ def test_scaffold_generator_password_digest
end
assert_file "app/views/users/_form.html.erb" do |content|
assert_match(/<%= form\.password_field :password, id: :user_password %>/, content)
assert_match(/<%= form\.password_field :password_confirmation, id: :user_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|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册