应该是 slim 写错的问题
= form_for(@blog) do |f|
- if @blog.errors.any?
#error_explanation
h2 = pluralize(@blog.errors.count,"error")
ul
= @blog.errors.full_messages.each do |msg|
li
= msg
.field
label for="title" Title
br
input type="text" name="title"
.field
label for="content" Content
br
textarea name="content"
.actions
input type="submit" value="POST IT!"
我添加标题和内容之后提交,还是显示 errors 并且输出的 html 有错误
<div id="error_explanation">
<h2>2 errors</h2>
<ul>
<li>Content can't be blank</li>
<li>Title can't be blank</li>
["Content can't be blank", "Title can't be blank"]
</ul>
</div>