【发布时间】:2014-03-25 23:34:09
【问题描述】:
我收到两次内容类型错误消息,如何删除第二个?
Document content type is not an acceptable type of document only pdf
Document ["is not an acceptable type of document only pdf"]
我试过这样做(就像我在其他帖子中看到的那样):
@document.errors.delete(:document)
但它消除了这两个错误。这是我用于验证的代码:
validates_attachment_content_type :document, :content_type => ["application/pdf"], :message => 'is not an acceptable type of document only pdf'
这是我用来显示错误的代码
发生错误<ul class="ml-30">
<% @errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
<li>Please change a few things up and try submitting again.</li>
</ul>
我怎样才能不只显示正确的错误消息?
【问题讨论】:
-
这是验证...但是您用来显示错误的代码在哪里?另外 - 这是什么
validates_attachment_content_type验证?这是你从某个图书馆得到的方法吗?因为它肯定不是标准的 Rails 验证 :) 如果您可以向我们展示该代码 - 也许我们可以修复它。 -
@Flezcano 你能分享你显示错误的视图代码吗?
-
谢谢,查看编辑
标签: ruby-on-rails