MongoDB-Uppgift/app/views/posts/_form.html.erb
2025-05-23 14:14:30 +02:00

27 lines
607 B
Text

<%= form_with(model: post) do |form| %>
<% if post.errors.any? %>
<div style="color: red">
<h2><%= pluralize(post.errors.count, "error") %> prohibited this post from being saved:</h2>
<ul>
<% post.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
</div>
<% end %>
<div>
<%= form.label :title, style: "display: block" %>
<%= form.text_field :title %>
</div>
<div>
<%= form.label :body, style: "display: block" %>
<%= form.textarea :body %>
</div>
<div>
<%= form.submit %>
</div>
<% end %>