有没有办法防止Paperclip上传验证出现两次?
这是我的模型:
has_attached_file :photo, :styles => { :thumb => "215x165" }, :default_url => "/images/:style/missing.png"
validates_attachment :photo, :presence => true,
:content_type => { :content_type => "image/jpg" },
:size => { :in => 0..0.5.megabytes }
这是我的观点:
<% if @product.errors.any? %>
<p>The following errors were found:</p>
<ul>
<% @product.errors.full_messages.each do |message| %>
<li>- <%= message %></li>
<% end %>
</ul>
<% end %>
如果我上传一个无效的文件,我会收到以下错误消息:
- 照片内容类型无效
- 照片无效
有没有办法只显示其中一个?我已经尝试将message:添加到模型中。但是这样也会出现两次!
谢谢!