Skip to content

Instantly share code, notes, and snippets.

@nicedawg
Last active February 22, 2020 23:14
Show Gist options
  • Save nicedawg/3bbe6f0f25443bcf8bc86dd03d30ef39 to your computer and use it in GitHub Desktop.
Save nicedawg/3bbe6f0f25443bcf8bc86dd03d30ef39 to your computer and use it in GitHub Desktop.
[Beginning Rails 6] Listing 8-5. User Form Partial in app/views/users/_form.html.erb
<%= form_with(model: user, local: true) do |form| %>
<% if user.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(user.errors.count, "error") %> prohibited this user from being saved:</h2>
<ul>
<% user.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= form.label :email %>
<%= form.text_field :email %>
</div>
<div class="field">
<%= form.label :password %>
<%= form.password_field :password %>
</div>
<div class="field">
<%= form.label :password_confirmation %>
<%= form.password_field :password_confirmation %>
</div>
<div class="actions">
<%= form.submit %>
</div>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment