0
1. validates :note, presence: true, length: { minimum: 6, maximum: 140 }

通过在输入字段正下方显示“ too short!”或“ ”错误消息提示,这将在我的 simple_form 中显示得很好。too long!

2. validates :user_id, uniqueness: { scope: [:year, :month, :day], message: "one person only allow one entry every day" }

表格代码:

<%= simple_form_for(@worktime) do |f| %>
  <%= f.error_notification %>
  <div class="form-inputs">
    <%= f.input :note, label: false, as: :text, placeholder: 'please comment here' %>
    <%= f.submit 'submit' %>
  </div>
<% end %>

这会以常规形式显示,但不会以我的 simple_form 显示,我不知道为什么?

提前非常感谢!

Ruby 2.3.3, rails 5.0.1

4

0 回答 0